当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMethods::addStrategy方法代码示例

本文整理汇总了PHP中Zend\Stdlib\Hydrator\ClassMethods::addStrategy方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMethods::addStrategy方法的具体用法?PHP ClassMethods::addStrategy怎么用?PHP ClassMethods::addStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Stdlib\Hydrator\ClassMethods的用法示例。


在下文中一共展示了ClassMethods::addStrategy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __invoke

 public function __invoke($services)
 {
     $hydrator = new ClassMethods();
     $hydrator->addStrategy('createdDatetime', new DatetimeStrategy());
     $hydrator->addStrategy('lastModified', new DatetimeStrategy());
     return $hydrator;
 }
开发者ID:nobesnickr,项目名称:ApiTimesheets,代码行数:7,代码来源:EntityHydratorFactory.php

示例2: getHydrator

 /**
  * Return an instance of ClassMethods
  *
  * @return ClassMethods
  */
 protected function getHydrator()
 {
     if (!isset($this->hydrator)) {
         $hydrator = new ClassMethods();
         $hydrator->addStrategy('coord', new CoordStrategy());
         $hydrator->addStrategy('sun', new SunStrategy());
         $this->hydrator = $hydrator;
     }
     return $this->hydrator;
 }
开发者ID:monkeyphp,项目名称:open-weather-map,代码行数:15,代码来源:CityStrategy.php

示例3: createService

 /**
  * @return ClassMethodsHydrator
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $serviceLocator = FactoryUtils::resolveServiceLocator($serviceLocator);
     $objectManager = $serviceLocator->get('doctrine.entitymanager.orm_default');
     $hydrator = new ClassMethodsHydrator(false);
     $hydrator->addStrategy('client', new EntityStrategy($objectManager->getRepository('Ajasta\\Client\\Entity\\Client')));
     $hydrator->addStrategy('project', new EntityStrategy($objectManager->getRepository('Ajasta\\Client\\Entity\\Project')));
     $hydrator->addStrategy('issueDate', new DateStrategy());
     $hydrator->addStrategy('dueDate', new DateStrategy());
     return $hydrator;
 }
开发者ID:DavidHavl,项目名称:Ajasta,代码行数:14,代码来源:InvoiceHydratorFactory.php

示例4: getHydrator

 /**
  * Return an instance of ClassMethods hydrator
  *
  * @return ClassMethods
  */
 protected function getHydrator()
 {
     if (!isset($this->hydrator)) {
         $hydrator = new ClassMethods();
         $hydrator->addStrategy('location', new LocationStrategy());
         $hydrator->addStrategy('credit', new CreditStrategy());
         $hydrator->addStrategy('meta', new MetaStrategy());
         $hydrator->addStrategy('sun', new SunStrategy());
         $hydrator->addStrategy('forecast', new ForecastStrategy());
         $this->hydrator = $hydrator;
     }
     return $this->hydrator;
 }
开发者ID:monkeyphp,项目名称:open-weather-map,代码行数:18,代码来源:WeatherDataStrategy.php

示例5: find

 public function find($id)
 {
     $order = $this->ordersRepository->find($id);
     $client = $this->clientsRepository->findBy(['id' => $order->getClientId()])->current();
     $ptype = $this->ptypesRepository->findBy(['id' => $order->getPtypeId()])->current();
     $user = $this->usersRepository->findBy(['id' => $order->getUserId()])->current();
     $sql = $this->ordersRepository->getItemTable()->getSql();
     $select = $sql->select();
     $select->join('products', 'order_items.product_id = products.id', ['product_name' => 'name'])->where(['order_id' => $order->getId()]);
     $items = $this->ordersRepository->getItemTable()->selectWith($select);
     foreach ($items as $item) {
         $order->addItem($item);
     }
     $hydrator = new ClassMethods();
     $hydrator->addStrategy('items', new OrdersItemsHydratorStrategy(new ClassMethods()));
     $order->setClient($hydrator->extract($client));
     $order->setPtype($hydrator->extract($ptype));
     $order->setUser($hydrator->extract($user));
     $result = $hydrator->extract($order);
     unset($result['client_id']);
     unset($result['ptype_id']);
     unset($result['user_id']);
     unset($result['user']['username']);
     unset($result['user']['password']);
     return $result;
 }
开发者ID:netoudi,项目名称:apigility,代码行数:26,代码来源:OrdersService.php

示例6: 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;
 }
开发者ID:pay4later,项目名称:php-task,代码行数:35,代码来源:AbstractClassAdapter.php

示例7: 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')));
 }
开发者ID:shinesoftware-zf-modules,项目名称:Customer,代码行数:33,代码来源:CustomerForm.php

示例8: 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);
 }
开发者ID:FiftyNine,项目名称:ScpperDB,代码行数:8,代码来源:VoteDbSqlMapperFactory.php

示例9: getHydrator

 /**
  * Get Hydrator
  * @return ClassMethods
  */
 public function getHydrator()
 {
     if (!$this->hydrator) {
         // use underscore separated keys by default
         $this->hydrator = new ClassMethods();
         $this->hydrator->addStrategy('_id', new MongoIdStrategy());
     }
     return $this->hydrator;
 }
开发者ID:fourmation,项目名称:mongo,代码行数:13,代码来源:DbAbstract.php

示例10: init

 public function init()
 {
     $hydrator = new ClassMethods();
     $hydrator->addStrategy('birthdate', new DateTimeStrategy());
     $this->setAttribute('method', 'post');
     $this->setHydrator($hydrator)->setObject(new \Dummy\Entity\Dummy());
     $this->add(array('name' => 'name', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Company'))));
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'class' => 'btn btn-success', 'value' => _('Save'))));
     $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden')));
 }
开发者ID:eotg1910,项目名称:shineisp2,代码行数:10,代码来源:DummyForm.php

示例11: createService

 public function createService(ServiceLocatorInterface $services)
 {
     $service = new PostService();
     $service->setSqlService($services->get(SqlService::class));
     $hydrator = new ClassMethods();
     // Stupid MySQL...
     $hydrator->addStrategy('is_visible', new BooleanStrategy("1", "0"));
     $service->setPostHydrator($hydrator);
     return $service;
 }
开发者ID:pdizz,项目名称:pdizz-web,代码行数:10,代码来源:PostServiceFactory.php

示例12: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $hydrator = new ClassMethods();
     $namingStrat = new \Zend\Stdlib\Hydrator\NamingStrategy\MapNamingStrategy(array(DbViewPages::PAGEID => 'id', DbViewPages::PAGENAME => 'name', DbViewPages::REVISIONS => 'revisionCount', DbViewPages::STATUSID => 'status', DbViewPages::STATUS => '', DbViewPages::KINDID => 'kind', DbViewPages::KIND => ''));
     $hydrator->setNamingStrategy($namingStrat);
     $hydrator->addStrategy(DbViewPages::CREATIONDATE, new \Zend\Stdlib\Hydrator\Strategy\DateTimeFormatterStrategy('Y-m-d H:i:s'));
     $prototype = $serviceLocator->get('PagePrototype');
     return new PageDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewPages::TABLE, DbViewPages::PAGEID);
 }
开发者ID:FiftyNine,项目名称:ScpperDB,代码行数:10,代码来源:PageDbSqlMapperFactory.php

示例13: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $hydrator = new ClassMethods();
     $names = array(DbViewRevisions::REVISIONID => 'id', DbViewRevisions::REVISIONINDEX => 'index');
     $hydrator->setNamingStrategy(new MapNamingStrategy($names));
     $hydrator->addStrategy(DbViewRevisions::DATETIME, new \Zend\Stdlib\Hydrator\Strategy\DateTimeFormatterStrategy('Y-m-d H:i:s'));
     $prototype = $serviceLocator->get('RevisionPrototype');
     return new RevisionDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewRevisions::TABLE, DbViewRevisions::REVISIONID);
 }
开发者ID:FiftyNine,项目名称:ScpperDB,代码行数:10,代码来源:RevisionDbSqlMapperFactory.php

示例14: getHydrator

 /**
  * Return an instance of ClassMethods
  *
  * @return ClassMethods
  */
 protected function getHydrator()
 {
     if (!isset($this->hydrator)) {
         $hydrator = new ClassMethods(false);
         $hydrator->addStrategy("city", new CityStrategy());
         $hydrator->addStrategy('temperature', new TemperatureStrategy());
         $hydrator->addStrategy('humidity', new HumidityStrategy());
         $hydrator->addStrategy('pressure', new PressureStrategy());
         $hydrator->addStrategy('windSpeed', new WindSpeedStrategy());
         $hydrator->addStrategy('windDirection', new WindDirectionStrategy());
         $hydrator->addStrategy('clouds', new CloudsStrategy());
         $hydrator->addStrategy('precipitation', new PrecipitationStrategy());
         $hydrator->addStrategy('weather', new WeatherStrategy());
         $this->hydrator = $hydrator;
     }
     return $this->hydrator;
 }
开发者ID:monkeyphp,项目名称:open-weather-map,代码行数:22,代码来源:CurrentStrategy.php

示例15: find

 public function find($id)
 {
     $hydrator = new ClassMethods();
     $hydrator->addStrategy('items', new OrderItemHydratorStrategy(new ClassMethods()));
     $orderBusca = $this->tableGateway->select(['id' => $id]);
     $order = $orderBusca->current();
     $items = $this->orderItemTableGateway->select(['order_id' => $order->getId()]);
     foreach ($items as $item) {
         $order->addItems($item);
     }
     $res = $hydrator->extract($order);
     return $res;
 }
开发者ID:pedrohglobo,项目名称:apicodeedu,代码行数:13,代码来源:OrdersRepository.php


注:本文中的Zend\Stdlib\Hydrator\ClassMethods::addStrategy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。