本文整理汇总了PHP中Zend\Stdlib\Hydrator\ClassMethods类的典型用法代码示例。如果您正苦于以下问题:PHP ClassMethods类的具体用法?PHP ClassMethods怎么用?PHP ClassMethods使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ClassMethods类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setComments
public function setComments($comments)
{
$hydrator = new ClassMethods();
foreach ($comments as $c) {
$this->comments[] = $hydrator->hydrate($c, new Comment());
}
}
示例2: persist
public function persist(array $data, $id = null)
{
if (empty($data['password'])) {
unset($data['password']);
}
$data['role'] = $this->em->getReference("Zf2Acl\\Entity\\Role", $data['role']);
if ($id) {
$entity = $this->em->getReference($this->entity, $id);
$entity_perfil = $this->em->getReference("Zf2User\\Entity\\Perfil", $data['perfil']['id']);
$hydrator = new Hydrator\ClassMethods();
$hydrator->hydrate($data, $entity);
$data['perfil']['user'] = $entity;
$hydrator->hydrate($data['perfil'], $entity_perfil);
} else {
$entity = new $this->entity($data);
$data['perfil']['user'] = $entity;
$entity_perfil = new \Zf2User\Entity\Perfil($data['perfil']);
}
$this->em->persist($entity);
$this->em->persist($entity_perfil);
$this->em->flush();
if ($entity->getStatus() == 0) {
// $dataEmail = array('email' => $entity->getEmail(), 'activationKey' => $entity->getActivationKey());
// $mail = new Mail($this->transport, $this->view, 'add-user');
// $mail->setSubject('Confirmação de cadastro')
// ->setTo($entity->getEmail())
// ->setData($dataEmail)
// ->prepare()
// ->send();
}
return $entity;
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$inputFile = new SplFileInfo($input->getArgument('input'));
$tag = $inputFile->getMetadata()->getId3v1Tag();
$hydrator = new ClassMethods();
$data = $hydrator->extract($tag);
$data['audio_properties'] = $hydrator->extract($data['audio_properties']);
foreach (array_keys($data) as $name) {
if (null === $data[$name]) {
unset($data[$name]);
}
}
$format = $input->getOption('format');
if (!in_array($format, array(self::FORMAT_YAML))) {
$format = self::FORMAT_YAML;
}
switch ($format) {
case self::FORMAT_YAML:
$data = Yaml::dump($data);
break;
}
$outputFilename = $input->getArgument('output');
if (null === $outputFilename) {
$output->writeln('<info>' . $data . '</info>');
return;
}
if (file_put_contents($outputFilename, $data)) {
$output->writeln(sprintf('<info>Metadata file \'%s\' successfully exported.</info>', $outputFilename));
return;
}
$output->writeln(sprintf('<error>Unable to write metadata file \'%s\'.</error>', $outputFilename));
}
示例4: extract
public function extract($object)
{
$classMethods = new ClassMethods();
$properties = $classMethods->extract($object);
unset($properties['alternative']);
return $properties;
}
示例5: init
public function init()
{
$hydrator = new ClassMethods();
$hydrator->addStrategy('birthdate', new DateTimeStrategy());
$this->setAttribute('method', 'post');
$this->setHydrator($hydrator)->setObject(new \Customer\Entity\Customer());
$this->add(array('name' => 'company', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Company'))));
$this->add(array('name' => 'firstname', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('First name'))));
$this->add(array('name' => 'lastname', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Last name'))));
$this->add(array('name' => 'note', 'attributes' => array('type' => 'textarea', 'class' => 'wysiwyg'), 'options' => array('label' => _('Private Notes'))));
$this->add(array('name' => 'birthdate', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth date'))));
$this->add(array('name' => 'birthplace', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth place'))));
$this->add(array('name' => 'birthdistrict', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth district'))));
$this->add(array('name' => 'birthcountry', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth country'))));
$this->add(array('name' => 'birthnationality', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth nationality'))));
$this->add(array('name' => 'taxpayernumber', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Tax payer number'))));
$this->add(array('name' => 'vat', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('VAT'))));
$this->add(array('type' => 'Customer\\Form\\Element\\CustomerGroup', 'name' => 'group_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Customer Group'))));
$this->add(array('type' => 'Base\\Form\\Element\\Languages', 'name' => 'language_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Language'))));
$this->add(array('type' => 'Customer\\Form\\Element\\Legalform', 'name' => 'legalform_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Legal form'))));
$this->add(array('type' => 'Customer\\Form\\Element\\Companytype', 'name' => 'type_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Company Type'))));
$this->add(array('type' => 'Customer\\Form\\Element\\Status', 'name' => 'status_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Status'), 'section' => 'customers')));
$this->add(array('type' => 'Zend\\Form\\Element\\File', 'name' => 'file', 'attributes' => array('class' => ''), 'options' => array('label' => _('Upload Document')), 'filters' => array(array('required' => false))));
$this->add(array('name' => 'contact', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Contact'))));
$this->add(array('type' => 'Customer\\Form\\Element\\ContactType', 'name' => 'contacttype', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Contact Type'))));
$this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'gender', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Gender'), 'value_options' => array('M' => _('Male'), 'F' => _('Female')))));
// This is a fieldset
$this->add(array('name' => 'address', 'type' => '\\Customer\\Form\\Fieldset\\AddressFieldset', 'object' => '\\Customer\\Entity\\Address', 'options' => array('use_as_base_fieldset' => false)));
$this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'class' => 'btn btn-success', 'value' => _('Save'))));
$this->add(array('name' => 'user_id', 'attributes' => array('type' => 'hidden')));
$this->add(array('name' => 'uid', 'attributes' => array('type' => 'hidden')));
$this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden')));
}
示例6: __invoke
public function __invoke($services)
{
$hydrator = new ClassMethods();
$hydrator->addStrategy('createdDatetime', new DatetimeStrategy());
$hydrator->addStrategy('lastModified', new DatetimeStrategy());
return $hydrator;
}
示例7: buildHydrator
protected function buildHydrator($product, $direction)
{
$this->assertOptionsValid();
$config = $this->options->getConfig();
$class = $this->options->getClass();
$hydrator = new ClassMethods();
if (!isset($config[$this->options->getClass()][$product])) {
return $hydrator;
}
$tmp = new Config(array());
if (isset($config[$class]['*'])) {
$tmp = new Config($config[$class]['*']);
}
if (isset($config[$class][$product])) {
$productConfig = new Config($config[$class][$product]);
$tmp = $productConfig->merge($tmp);
}
$config = $tmp['shared'];
if (isset($tmp[$direction])) {
$config->merge($tmp[$direction]);
}
$config = $config->toArray();
if (!empty($config['map'])) {
$hydrator->setNamingStrategy(new ArrayMapNamingStrategy($config['map']));
}
if (!empty($config['strategy'])) {
foreach ($config['strategy'] as $name => $strategyCallback) {
$hydrator->addStrategy($name, $strategyCallback());
}
}
if (!empty($config['options'])) {
$this->options->setFromArray($config['options']);
}
return $hydrator;
}
示例8: __construct
public function __construct($data = null)
{
if (null !== $data) {
$hydrator = new \Zend\Stdlib\Hydrator\ClassMethods();
$hydrator->hydrate($data, $this);
}
}
示例9: setArticles
public function setArticles($articles)
{
$hydrator = new ClassMethods();
foreach ($articles as $a) {
$this->articles[] = $hydrator->hydrate($a, new Article());
}
}
示例10: fetch
public function fetch()
{
$authenticatedIdentity = $this->getApiIdentity();
if ($authenticatedIdentity instanceof GuestIdentity) {
$identity = $_SERVER['REMOTE_ADDR'];
} elseif ($authenticatedIdentity instanceof AuthenticatedIdentity) {
$identityDetails = $authenticatedIdentity->getAuthenticationIdentity();
if (array_key_exists('client_id', $identityDetails)) {
$identity = $identityDetails['client_id'];
} else {
$identity = $_SERVER['REMOTE_ADDR'];
}
} else {
throw new \InvalidArgumentException('Invalid Identity Type Provided');
}
if (array_key_exists($identity, $this->getConfig())) {
$clientConfigArray = $this->getConfig()[$identity];
}
if (empty($clientConfigArray)) {
$clientConfigArray = $this->getConfig()['default'];
}
$clientRateLimitConfig = new ClientRateLimitConfig();
$hydrator = new ClassMethods();
$hydrator->hydrate($clientConfigArray, $clientRateLimitConfig);
$clientRateLimitConfig->setIdentity($identity);
return $clientRateLimitConfig;
}
示例11: createService
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$classmethod = new ClassMethods(false);
$classmethod->addFilter("arraycoppy", new MethodMatchFilter("getArrayCopy"), FilterComposite::CONDITION_AND);
$classmethod->addFilter("inputFilter", new MethodMatchFilter("getInputFilter"), FilterComposite::CONDITION_AND);
return new UserService($serviceLocator->get('Zend\\Db\\Adapter\\Adapter'), $classmethod);
}
示例12: saveVideo
public function saveVideo(VideosEntity $ent)
{
$hydrator = new ClassMethods();
$data = $hydrator->extract($ent);
$select = $this->sql->select();
$whereArr = array('video_id' => $ent->getVideoId());
$select->where($whereArr);
$statement = $this->sql->prepareStatementForSqlObject($select);
$results = $statement->execute();
$result = false;
if ($results->count() == 0) {
// insert action
$action = $this->sql->insert();
$action->values($data);
$statement = $this->sql->prepareStatementForSqlObject($action);
$result = $statement->execute();
} elseif (false && $results->count() > 0) {
// update action
$action = $this->sql->update();
unset($data['id']);
$action->set($data);
$action->where(array('video_id' => $ent->getVideoId()));
}
return $result;
}
示例13: fromArray
public function fromArray($values)
{
$hydrator = new Hydrator\ClassMethods();
$hydrator->setUnderscoreSeparatedKeys(false);
$res = $hydrator->hydrate($values, $this);
return $res;
}
示例14: toArray
public function toArray()
{
$hydrator = new ClassMethods();
$data = $hydrator->extract($this);
$data['perfil'] = $data['usuario']->getGrupo()->getId();
$data['login'] = $data['usuario']->getLogin();
return $data;
}
示例15: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
$hydrator = new ClassMethods();
$hydrator->addStrategy(DbViewVotes::DATETIME, new DateTimeFormatterStrategy('Y-m-d H:i:s'));
$prototype = $serviceLocator->get('VotePrototype');
return new VoteDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewVotes::TABLE, DbViewVotes::__ID);
}