本文整理汇总了PHP中Zend\Stdlib\Hydrator\ClassMethods::setNamingStrategy方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMethods::setNamingStrategy方法的具体用法?PHP ClassMethods::setNamingStrategy怎么用?PHP ClassMethods::setNamingStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Stdlib\Hydrator\ClassMethods
的用法示例。
在下文中一共展示了ClassMethods::setNamingStrategy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
$hydrator = new ClassMethods();
$names = array(DbViewSites::SITEID => 'id');
$hydrator->setNamingStrategy(new MapNamingStrategy($names));
$prototype = $serviceLocator->get('SitePrototype');
return new SiteDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewSites::TABLE, DbViewSites::SITEID);
}
示例3: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
$hydrator = new ClassMethods();
$names = new \Zend\Stdlib\Hydrator\NamingStrategy\MapNamingStrategy(array(DbViewAuthors::ROLEID => 'role'));
$hydrator->setNamingStrategy($names);
$prototype = $serviceLocator->get('AuthorshipPrototype');
return new AuthorshipDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewAuthors::TABLE, '');
}
示例4: 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);
}
示例5: 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);
}