當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。