本文整理汇总了PHP中Mapper类的典型用法代码示例。如果您正苦于以下问题:PHP Mapper类的具体用法?PHP Mapper怎么用?PHP Mapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEmptyElementIfIsReference
public function testEmptyElementIfIsReference()
{
$m = new Mapper($this->project);
$m->setFrom("*.java");
try {
$m->setRefid(new Reference("dummyref"));
$this->fail("Can add reference to Mapper with from attribute set");
} catch (BuildException $be) {
$this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
}
$m = new Mapper($this->project);
$m->setRefid(new Reference("dummyref"));
try {
$m->setFrom("*.java");
$this->fail("Can set from in Mapper that is a reference.");
} catch (BuildException $be) {
$this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
}
$m = new Mapper($this->project);
$m->setRefid(new Reference("dummyref"));
try {
$m->setTo("*.java");
$this->fail("Can set to in Mapper that is a reference.");
} catch (BuildException $be) {
$this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
}
try {
$m = new Mapper($this->project);
$m->setRefid(new Reference("dummyref"));
$m->setType("glob");
$this->fail("Can set type in Mapper that is a reference.");
} catch (BuildException $be) {
$this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
}
}
示例2: __construct
public function __construct(Mapper $mapper, array $namespaces, array $paths)
{
$this->mapper = $mapper;
$this->namespaces = $namespaces;
$this->paths = $paths;
$this->tables = $this->mapper->generate();
}
示例3: testMapperWithDefaultValue
public function testMapperWithDefaultValue()
{
require_once __DIR__ . '/helpers/MapperTestDefaultHelper.php';
$mapper = new Mapper();
$class = $mapper->mapInputToCommand('MapperTestDefaultHelper', []);
$this->assertEquals('456', $class->test);
}
示例4: login
function login()
{
if (!empty($_POST)) {
$check = new Check();
$user = new User();
$pdo = new Db();
$db = $pdo->get();
$mapper = new Mapper($db);
//Проверяем входные данные
$user->login = $check->checkInput($_POST['login']);
$password = $check->checkInput($_POST['pass']);
$user->password = md5($password);
//Если пользователь не найден
$this->user = $mapper->select($user);
if (empty($this->user)) {
$this->error = "Пароль или логин не совпадают";
$this->out('login.php');
} else {
$this->out('profile.php');
//Если найден, выводим профиль
}
} else {
$this->out('login.php');
}
}
示例5: add
/**
* Add file in given feed
* @return bool
*/
public static function add($feedID, $files, $ssh_connection)
{
// set permissions with the ssh connection
// get feed path
$mapper = new Mapper('Feed');
$mapper->get($feedID);
$resultsFeed = $mapper->get();
$mapper = new Mapper('User');
$mapper->get($resultsFeed['Feed'][0]->user_id);
$resultsUser = $mapper->get();
// target directory
$dir = CHRIS_USERS . '/' . $resultsUser['User'][0]->username . '/file_browser/' . $resultsFeed['Feed'][0]->name . '-' . $resultsFeed['Feed'][0]->id . '/';
$ssh_connection->exec('chmod 777 ' . $dir);
foreach ($files as $key => $value) {
$target_path = $dir . basename($value['name']);
if (move_uploaded_file($value['tmp_name'], $target_path)) {
// all good, set permissions correctly
// not through ssh connection, do it as chris
exec('chmod 775 ' . $target_path);
} else {
// oops.... something went wrong
return $value['error'];
}
$ssh_connection->exec('chmod 755 ' . $dir);
}
// all files uploaded successfully
return 0;
}
示例6: __construct
/**
* Constructor Method
*
* @param \Spot\Mapper $mapper
* @throws Exception
* @internal param $Spot_Mapper
* @internal param string $entityName Name of the entity to query on/for
*/
public function __construct(Mapper $mapper)
{
$this->_mapper = $mapper;
$this->_entityName = $mapper->entity();
$this->_tableName = $mapper->table();
// Create Doctrine DBAL query builder from Doctrine\DBAL\Connection
$this->_queryBuilder = $mapper->connection()->createQueryBuilder();
}
示例7: add
/**
* Add a <code>FileNameMapper</code>.
* @param FileNameMapper $fileNameMapper a <code>FileNameMapper</code>.
* @throws BadMethodCallException if attempting to add this
* <code>ContainerMapper</code> to itself, or if the specified
* <code>FileNameMapper</code> is itself a <code>ContainerMapper</code>
* that contains this <code>ContainerMapper</code>.
*/
public function add(Mapper $fileNameMapper)
{
if ($this == $fileNameMapper || $fileNameMapper instanceof ContainerMapper && $fileNameMapper->contains($this)) {
throw new BadMethodCallException("Circular mapper containment condition detected");
} else {
$this->mappers[] = $fileNameMapper;
}
}
示例8: savelike
function savelike($like, $itemid)
{
$pdo = new Db();
$db = $pdo->get();
$mapper = new Mapper($db);
$comments = new Comments();
$comments->likes = $like;
$comments->id = $itemid;
$mapper->saveLike($comments);
}
示例9: validate
/**
* Validate a token. Returns the result and deletes the token if valid.
*
* @param string $token The token
* @return boolean
*/
public static function validate($token)
{
$tokenMapper = new Mapper('Token');
$tokenMapper->filter('value=(?)', $token);
$tokenResults = $tokenMapper->get();
if (count($tokenResults['Token']) == 0) {
return false;
}
// we found the token
Mapper::delete($tokenResults['Token'][0], $tokenResults['Token'][0]->id);
return true;
}
示例10: writeOptionsFromObject
/**
* FormTools::WriteOptionsFromObject()
* Prend en paramètres un nom d'objet et retourne un tableau
* d'options de type:
* <code>
* [0=>'<option value="1">Label1</option>',
* 1=>'<option value="2">Label2</option>']
* </code>
*
* @static
* @param string $objname le nom de l'objet
* @param mixed $selID la ou les valeurs selectionnées par défaut
* @param mixed array or Filter: un filtre optionnel à appliquer
* @param array $sort un tableau optionnel pour le tri
* @param string $labelMethod la méthode à utiliser pour le label
* @param array $fields les attributs à récupérer.
* @param boolean $addNullEntry true pour ajouter une option 'Sélectionnez
* un élément'
* @return array the options array
*/
static function writeOptionsFromObject($objname, $selID = 0, $filter = array(), $sort = array(), $labelmethod = 'toString', $fields = array(), $addNullEntry = false)
{
$options = array();
$mapper = Mapper::singleton($objname);
if (Tools::isException($mapper)) {
return $mapper;
}
if ($labelmethod == 'toString') {
$toStringAttribute = Tools::getToStringAttribute($objname);
$fields = is_array($toStringAttribute) ? $toStringAttribute : array($toStringAttribute);
}
$col = $mapper->loadCollection($filter, $sort, $fields);
if ($col instanceof Collection) {
$dataArray = array();
$count = $col->getCount();
for ($i = 0; $i < $count; $i++) {
$item = $col->getItem($i);
if (method_exists($item, 'getId') && method_exists($item, $labelmethod)) {
$dataArray[$item->getId()] = $item->{$labelmethod}();
}
unset($item);
}
$options = FormTools::writeOptionsFromArray($dataArray, $selID, $addNullEntry);
}
return $options;
}
示例11: write
public static function write($name, $value, $expires = null)
{
$self = self::getInstance();
$expires = $self->expire($expires);
$path = Mapper::normalize(Mapper::base() . $self->path);
return setcookie($self->name . '[' . $name . ']', self::encrypt($value), $expires, $path, $self->domain, $self->secure);
}
示例12: verifySettings
/**
* Checks to make sure all settings are kosher. In this case, it
* means that the dest attribute has been set and we have a mapper.
*/
public function verifySettings()
{
if ($this->targetdir === null) {
$this->setError("The targetdir attribute is required.");
}
if ($this->map === null) {
if ($this->mapperElement === null) {
$this->map = new IdentityMapper();
} else {
$this->map = $this->mapperElement->getImplementation();
if ($this->map === null) {
$this->setError("Could not set <mapper> element.");
}
}
}
}
示例13: getComputed
/**
* Returns lazy loaded field by its name
*
* @param string $fieldName
* @return mixed
*/
public function getComputed($fieldName)
{
if (!isset($this->computed[$fieldName])) {
$value = $this->mapper->lazyload($this, $fieldName);
$this->computed[$fieldName] = $value;
}
return $this->computed[$fieldName];
}
示例14: registerAdapter
public function registerAdapter($name, Adapter $adapter)
{
if (isset($this->adapters[$name])) {
throw new Exception\InvalidArgumentException("Adapter with name " . $name . " already registered!");
}
$this->adapters[$name] = $adapter;
if ($adapter->getMapping()) {
$this->mapper->registerAdapterMapping($name, $adapter->getMapping());
}
}
示例15: get
public function get(array $hashMap, $isNestedKeysName = false)
{
$pattern = $this->getPattern($isNestedKeysName);
$this->mapper->match($pattern, [$hashMap]);
$data = $this->mapper->current();
if (empty($data)) {
$result = $this->getEmptyArray($pattern);
} else {
$result = $this->arrayHelper->toTuple($data, $pattern);
}
return $result;
}