コード例 #1
0
 /**
  * @dataProvider findProvider
  */
 public function testFind($criteria, $order, $direction, $clearBlacklist, $expectedOrder, $expectedResult)
 {
     if ($clearBlacklist) {
         static::$serviceManager->get('Database\\Table\\DuplicateMacAddresses')->delete(true);
         static::$serviceManager->get('Database\\Table\\DuplicateSerials')->delete(true);
         static::$serviceManager->get('Database\\Table\\DuplicateAssetTags')->delete(true);
     }
     $ordercolumns = array('Id' => 'clients.id', 'Name' => 'clients.name', 'NetworkInterface.MacAddress' => 'networkinterface_macaddr');
     $sql = new \Zend\Db\Sql\Sql(static::$serviceManager->get('Db'), 'clients');
     $select = $sql->select()->columns(array('id', 'name', 'lastcome', 'ssn', 'assettag'))->order(array($ordercolumns[$order] => $direction));
     $clientManager = $this->createMock('Model\\Client\\ClientManager');
     $clientManager->method('getClients')->with(array('Id', 'Name', 'LastContactDate', 'Serial', 'AssetTag'), $order, $direction, null, null, null, null, false, false, false)->willReturn($select);
     $clients = $this->getMockBuilder('Database\\Table\\Clients')->disableOriginalConstructor()->setMethods(array('getSql', 'selectWith'))->getMock();
     $clients->method('getSql')->willReturn($sql);
     $clients->method('selectWith')->with($this->callback(function ($select) use($expectedOrder) {
         return $select->getRawState($select::ORDER) == $expectedOrder;
     }))->willReturnCallback(function ($select) use($sql) {
         // Build simple result set to bypass hydrator
         $resultSet = new \Zend\Db\ResultSet\ResultSet();
         $resultSet->initialize($sql->prepareStatementForSqlObject($select)->execute());
         return $resultSet;
     });
     $duplicates = $this->_getModel(array('Database\\Table\\Clients' => $clients, 'Model\\Client\\ClientManager' => $clientManager));
     $resultSet = $duplicates->find($criteria, $order, $direction);
     $this->assertInstanceOf('Zend\\Db\\ResultSet\\AbstractResultSet', $resultSet);
     $this->assertEquals($expectedResult, $resultSet->toArray());
 }
コード例 #2
0
 public static function getServiceConfig($owner, $modelName, $table, $mapper)
 {
     $adapter = static::getAdapter($owner);
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->setArrayObjectPrototype(new $modelName());
     $tableGateway = new \Zend\Db\TableGateway\TableGateway($table, $adapter, null, $resultSet);
     $returning_mapper = new $mapper($tableGateway);
     return $returning_mapper;
 }
コード例 #3
0
 /** {@inheritdoc} */
 protected function _getForm()
 {
     $groups = array(array('Name' => 'group1'), array('Name' => 'group2'));
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->initialize($groups);
     $this->_groupManager->expects($this->once())->method('getGroups')->with(null, null, 'Name')->willReturn($resultSet);
     $form = new \Console\Form\AddToGroup(null, array('GroupManager' => $this->_groupManager));
     $form->init();
     return $form;
 }
コード例 #4
0
 /**
  * action index
  * @return \Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     /**
      * função anônima para var_dump estilizado
      */
     $myVarDump = function ($nome_linha = "Nome da Linha", $data = null, $caracter = ' - ') {
         echo str_repeat($caracter, 100) . '<br/>' . ucwords($nome_linha) . '<pre><br/>';
         var_dump($data);
         echo '</pre>' . str_repeat($caracter, 100) . '<br/><br/>';
     };
     /**
      * Uso de cache
      */
     if (!$this->cache()->hasItem('nome')) {
         $myVarDump("Registro de Cache Agora", $this->cache()->setItem('nome', 'igor'));
     } else {
         $myVarDump("Cache Existente", $this->cache()->getItem('nome'));
     }
     /**
      * conexão com banco
      */
     /* $adapter = new Adaptador(array( // alias use Zend\Db\Adapter\Adapter as Adaptador
            'driver'    => 'Pdo_Mysql',
            'database'  => 'agenda_contatos',
            'username'  => 'tutorialzf2',
            'password'  => '!nF&rn0d3d4nt&'
        ));*/
     $adapter = $this->getServiceLocator()->get('AdapterDb');
     /**
      * obter nome do schema do nosso banco
      */
     $myVarDump("Nome Schema", $adapter->getCurrentSchema());
     /**
      * contar quantidade de elementos da nossa tabela
      */
     $myVarDump("Quantidade elementos tabela contatos", $adapter->query("SELECT * FROM `contatos`")->execute()->count());
     /**
      * montar objeto sql e executar
      */
     $sql = new Sql($adapter);
     // use Zend\Db\Sql\Sql
     $select = $sql->select()->from('contatos');
     $statement = $sql->prepareStatementForSqlObject($select);
     $resultsSql = $statement->execute();
     $myVarDump("Objet Sql com Select executado", $resultsSql);
     /**
      * motar objeto resultset com objeto sql e mostrar resultado em array
      */
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     // nao necessita do use devido a sintaxe iniciando em \
     $resultSet->initialize($resultsSql);
     $myVarDump("Resultado do Objeto Sql para Array ", $resultSet->toArray());
     die;
 }
コード例 #5
0
ファイル: FacebookColl.php プロジェクト: caiofior/cercaziende
 /**
  * Count items
  * @return int
  */
 public function countAll($criteria = array())
 {
     $select = $this->content->getTable()->getSql()->select()->columns(array(new \Zend\Db\Sql\Expression('COUNT(*)')));
     $select = $this->setFilter($select, $criteria);
     $statement = $this->content->getTable()->getSql()->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->initialize($results);
     $data = $resultSet->current()->getArrayCopy();
     return intval(array_pop($data));
 }
コード例 #6
0
ファイル: BaseMapper.php プロジェクト: nowarena/zf2NowArena
 protected function arrayResult($select)
 {
     $statement = $this->sql->prepareStatementForSqlObject($select);
     // echo "<br><br>".$select->getSqlString($this->dbAdapter->getPlatform());
     $results = $statement->execute();
     // $results->current();
     if ($results->count() > 0) {
         $rows = new \Zend\Db\ResultSet\ResultSet();
         return $rows->initialize($results)->toArray();
     }
     return false;
 }
コード例 #7
0
ファイル: SearchTest.php プロジェクト: hschletz/braintacle
 public function testInitInvalidDatatype()
 {
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->initialize(array());
     $registryManager = $this->createMock('Model\\Registry\\RegistryManager');
     $registryManager->method('getValueDefinitions')->willReturn($resultSet);
     $customFieldManager = $this->createMock('Model\\Client\\CustomFieldManager');
     $customFieldManager->expects($this->once())->method('getFields')->willReturn(array('test' => 'invalid'));
     $form = new \Console\Form\Search(null, array('translator' => new \Zend\Mvc\I18n\Translator(new \Zend\Mvc\I18n\DummyTranslator()), 'registryManager' => $registryManager, 'customFieldManager' => $customFieldManager));
     $this->setExpectedException('UnexpectedValueException');
     $form->init();
 }
コード例 #8
0
 /**
  *
  * @param unknown $sql        	
  * @return \Zend\Db\ResultSet\ResultSet|multitype:
  */
 private function _getResult($sql)
 {
     $stmt = $this->gateway->getAdapter()->createStatement($sql);
     $stmt->prepare();
     $result = $stmt->execute();
     if ($result->isQueryResult()) {
         $resultSet = new \Zend\Db\ResultSet\ResultSet();
         $resultSet->initialize($result);
         return $resultSet;
     }
     return array();
 }
コード例 #9
0
 protected function createOpportunity(array $data)
 {
     $sm = $this->getServiceLocator();
     $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
     $resultSetPrototype->setArrayObjectPrototype(new \Opportunity\Model\Opportunity());
     $tableGateway = new \Zend\Db\TableGateway\TableGateway('user', $dbAdapter, null, $resultSetPrototype);
     $opportunity = new Opportunity();
     $opportunity->exchangeArray($data);
     $opportunityTable = new OpportunityTable($tableGateway);
     $opportunityTable->saveOpportunity($opportunity);
     return true;
 }
コード例 #10
0
 protected function createUser(array $data)
 {
     $sm = $this->getServiceLocator();
     $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
     $resultSetPrototype->setArrayObjectPrototype(new \Users\Model\User());
     $tableGateway = new \Zend\Db\TableGateway\TableGateway('user', $dbAdapter, null, $resultSetPrototype);
     $user = new User();
     $user->exchangeArray($data);
     $userTable = new UserTable($tableGateway);
     $userTable->saveUser($user);
     return true;
 }
コード例 #11
0
 protected function createProduct(array $data)
 {
     $sm = $this->getServiceLocator();
     $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
     $resultSetPrototype->setArrayObjectPrototype(new \Store\Model\Product());
     $tableGateway = new \Zend\Db\TableGateway\TableGateway('product', $dbAdapter, null, $resultSetPrototype);
     $product = new Product();
     $product->exchangeArray($data);
     $productTable = new ProductTable($tableGateway);
     $productTable->saveProduct($product);
     return true;
 }
コード例 #12
0
 public function getServiceConfig()
 {
     return array('factories' => array('Album\\Model\\AlbumTable' => function ($sm) {
         $tableGateway = $sm->get('AlbumTableGateway');
         $table = new Model\AlbumTable($tableGateway);
         return $table;
     }, 'AlbumTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Model\Album());
         return new \Zend\Db\TableGateway\TableGateway('album', $dbAdapter, null, $resultSetPrototype);
     }));
 }
コード例 #13
0
ファイル: AlbumTable.php プロジェクト: michaelpedrotti/zend2
 public function fetchAll($paginated = false)
 {
     if ($paginated) {
         // create a new Select object for the table album
         $select = new \Zend\Db\Sql\Select('album');
         // create a new result set based on the Album entity
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Album());
         // create a new pagination adapter object
         $paginatorAdapter = new \Zend\Paginator\Adapter\DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
         $paginator = new \Zend\Paginator\Paginator($paginatorAdapter);
         return $paginator;
     }
     $resultSet = $this->tableGateway->select();
     return $resultSet;
 }
コード例 #14
0
ファイル: PersonColl.php プロジェクト: caiofior/cercaziende
 /**
  * Count items
  * @return int
  */
 public function countAll($criteria = array())
 {
     $select = $this->content->getTable()->getSql()->select()->columns(array(new \Zend\Db\Sql\Expression('COUNT(*)')));
     if (array_key_exists('filter', $criteria) && is_array($criteria['filter'])) {
         foreach ($criteria['filter'] as $field => $word) {
             if (is_string($word)) {
                 $select->where($field . ' LIKE"' . addslashes($word) . '%"');
             }
         }
     }
     $select = $this->setFilter($select, $criteria);
     $statement = $this->content->getTable()->getSql()->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->initialize($results);
     $data = $resultSet->current()->getArrayCopy();
     return intval(array_pop($data));
 }
コード例 #15
0
ファイル: TableFactory.php プロジェクト: sumiyoshi/BokunoZF2
 /**
  * @param ServiceLocatorInterface $locator
  * @param $name
  * @param $requestedName
  * @return AbstractTable
  */
 public function createServiceWithName(ServiceLocatorInterface $locator, $name, $requestedName)
 {
     $entityClass = 'Component\\Data\\Entity\\' . str_replace('Table', 'Entity', $requestedName);
     $recordClass = str_replace('Table', 'Model', $requestedName);
     $tableClass = 'Component\\Data\\Table\\' . $requestedName;
     /** @var \Zend\Db\Adapter\Adapter $adapter */
     $adapter = $locator->get('Zend\\Db\\Adapter\\Adapter');
     #region resultSet
     /** @var AbstractModel $record */
     $record = $locator->get($recordClass);
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->setArrayObjectPrototype($record);
     #endregion
     /** @var EntityInterface $entity */
     $entity = new $entityClass();
     $tableData = new \Zend\Db\TableGateway\TableGateway($entity->getTableName(), $adapter, null, $resultSet);
     $table = new $tableClass($tableData, $entity);
     return $table;
 }
コード例 #16
0
ファイル: ProductTable.php プロジェクト: zhznzw/hwizfms
 public function fetchAll($where = '', $order = '', $limit = '', $paginated = '')
 {
     if ($paginated) {
         $select = new \Zend\Db\Sql\Select('hwi_product');
         if (is_array($where)) {
             $select->where($where);
         }
         if (is_array($order)) {
             foreach ($order as $key => $value) {
                 $select->order($value);
             }
         }
         $rs = new \Zend\Db\ResultSet\ResultSet();
         $rs->setArrayObjectPrototype(new product());
         $pageAdapter = new \Zend\Paginator\Adapter\DbSelect($select, $this->tableGateway->getAdapter(), $rs);
         $paginator = new \Zend\Paginator\Paginator($pageAdapter);
         return $paginator;
     }
     $resultSet = $this->tableGateway->select($where, $order, $limit);
     return $resultSet;
 }
コード例 #17
0
 public function indexAction()
 {
     /* Instanciation d'un tableGateway pour country */
     $sm = $this->getServiceLocator();
     $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
     $resultSetPrototype->setArrayObjectPrototype(new Country());
     $tableGateWay = new TableGateway('country', $dbAdapter, null, $resultSetPrototype);
     $countryTable = new CountryTable($tableGateWay);
     $form = new Form\Register();
     $libelleValidation = "";
     if ($this->request->isPost()) {
         $dataPosted = $this->request->getPost();
         //var_dump($dataPosted);
         /* S'il a cliqué sur le bouton suppression, on supprime l'id, sinon c'est un create ou update */
         if (isset($dataPosted->suppression)) {
             $countryTable->deleteCountry($dataPosted->id);
         } else {
             $formReceivedData = new Form\Register();
             $formReceivedData->setData($dataPosted);
             if ($formReceivedData->isValid()) {
                 $libelleValidation = "Enregistrement effectué ";
                 $newCountry = new Country();
                 $newCountry->exchangeArray($dataPosted);
                 $countryTable->saveCountry($newCountry);
             } else {
                 $libelleValidation = "Les données inserées ne sont pas valides";
                 $form->setData($dataPosted);
             }
         }
     }
     //saveCountry
     $form2 = new Form\RegisterArrayLine();
     $allCountries = $countryTable->fetchAll();
     $viewModel = new ViewModel(["allCountries" => $allCountries, "form" => $form, "form2" => $form2, "libelleValidation" => $libelleValidation]);
     return $viewModel;
 }
コード例 #18
0
<?php

require __DIR__ . '/../include/pageboot.php';
$fName = 'php://stdout';
if (is_array($argv) && array_key_exists('1', $argv)) {
    $fName = $argv[1];
}
$fh = fopen($fName, 'w');
$statement = $GLOBALS['db']->query(' SELECT * FROM `person_to_person` WHERE or_codFisc <> "" AND codFisc <> ""');
$resultSet = new \Zend\Db\ResultSet\ResultSet();
$resultSet->initialize($statement->execute());
fwrite($fh, '"OR","DEST"' . PHP_EOL);
while ($resultSet->valid()) {
    $row = $resultSet->current();
    fwrite($fh, '"' . $row['or_codFisc'] . '","' . $row['codFisc'] . '"' . PHP_EOL);
    $resultSet->next();
}
fclose($fh);
コード例 #19
0
ファイル: install.php プロジェクト: Maxlander/shixi
 /**
  * @param  string $sql
  * @return array
  */
 function getQueryResult($sql)
 {
     $values = array();
     $db = Zend_Registry::get('db');
     try {
         $result = $db->getDriver()->getConnection()->execute($sql);
         if ($result->isQueryResult()) {
             $results = new Zend\Db\ResultSet\ResultSet();
             $values = $results->initialize($result)->toArray();
         }
     } catch (Exception $e) {
         $values = array();
     }
     return $values;
 }
コード例 #20
0
<?php

require __DIR__ . '/../include/pageboot.php';
$fName = 'php://stdout';
if (is_array($argv) && array_key_exists('1', $argv)) {
    $fName = $argv[1];
}
$fh = fopen($fName, 'w');
$statement = $GLOBALS['db']->query(' SELECT * FROM `company_to_company` WHERE or_partIVA <> 0 AND dest_partIVA != ""');
$resultSet = new \Zend\Db\ResultSet\ResultSet();
$resultSet->initialize($statement->execute());
fwrite($fh, '"OR","DEST"' . PHP_EOL);
while ($resultSet->valid()) {
    $row = $resultSet->current();
    if (is_array($argv) && array_key_exists('2', $argv)) {
        $statement1 = $GLOBALS['db']->query(' SELECT COUNT(*) FROM `company` WHERE 
            ( partIVA = "' . $row['or_partIVA'] . '" OR partIVA = "' . $row['dest_partIVA'] . '" )
            AND ' . $argv[2]);
        $resultSet1 = new \Zend\Db\ResultSet\ResultSet();
        $resultSet1->initialize($statement1->execute());
        $c = $resultSet1->current();
        if (current($c) == 0) {
            $resultSet->next();
            continue;
        }
    }
    fwrite($fh, '"' . $row['or_partIVA'] . '","' . $row['dest_partIVA'] . '"' . PHP_EOL);
    $resultSet->next();
}
fclose($fh);
コード例 #21
0
 public function singleRecordAction()
 {
     $retour = array();
     $iso = $this->params('iso3166');
     $request = new \Zend\Http\PhpEnvironment\Request();
     $methode = $request->getServer('REQUEST_METHOD');
     if (isset($iso)) {
         $retour["search"] = $iso;
         $sm = $this->getServiceLocator();
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Country());
         $tableGateWay = new TableGateway('country', $dbAdapter, null, $resultSetPrototype);
         $countryTable = new CountryTable($tableGateWay);
         switch ($methode) {
             case "GET":
                 $country = $countryTable->getCountryWithSearch($iso);
                 if (isset($country)) {
                     $retour[] = $country->toArray();
                 } else {
                     $retour["error"] = "Pas de resultat";
                 }
                 break;
             case "PATCH":
                 $country = $countryTable->getCountryWithSearch($iso);
                 if (isset($country)) {
                     $postContent = $request->getContent();
                     if (trim($postContent)) {
                         //$retour["content"] = json_decode($postContent);
                         $formReceivedData = new Form\Register();
                         $formReceivedData->setData(json_decode($postContent, true));
                         //$retour["insert"] = json_decode($postContent,true);
                         if ($formReceivedData->isValid()) {
                             $newCountry = new Country();
                             $newCountry->exchangeArray(json_decode($postContent, true));
                             $countryTable->saveCountry($newCountry);
                             $retour["success"] = "Donnees valides";
                         } else {
                             $retour["error"] = "Donnees recues non valides";
                         }
                     } else {
                         $retour["error"] = "Pas de donnees recues";
                     }
                 } else {
                     $retour["error"] = "Pays non trouve";
                 }
                 break;
             case "DELETE":
                 $country = $countryTable->getCountryWithSearch($iso);
                 if (isset($country)) {
                     $countryTable->deleteCountryWithSearch($iso);
                     $retour["success"] = "Suppression reussie";
                 } else {
                     $retour["error"] = "Pays non trouve";
                 }
                 break;
             default:
                 $retour["error"] = "405 : Forbidden method";
                 break;
         }
     } else {
         $retour["error"] = "Pas d'iso3166 specifie";
     }
     return new JsonModel($retour);
 }
コード例 #22
0
 public function testIndexActionMessages()
 {
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->initialize(array());
     $this->_groupManager->expects($this->once())->method('getGroups')->willReturn($resultSet);
     $flashMessenger = $this->_getControllerPlugin('FlashMessenger');
     $flashMessenger->addErrorMessage('error');
     $flashMessenger->addSuccessMessage('success');
     $this->_disableTranslator();
     $this->dispatch('/console/group/index/');
     $this->assertXpathQuery('//ul[@class="error"]/li[text()="error"]');
     $this->assertXpathQuery('//ul[@class="success"]/li[text()="success"]');
 }
コード例 #23
0
 public function testProcessRename()
 {
     $data = array('inspect' => array('inspect' => '1'), 'existing' => array('value_1_name' => 'name1_new', 'value_2_name' => 'name2'), 'new_value' => array('name' => '', 'root_key' => 'root_key', 'subkeys' => 'subkeys', 'value' => 'value'));
     $value1 = array('Id' => 1, 'Name' => 'name1', 'FullPath' => 'path1');
     $value2 = array('Id' => 2, 'Name' => 'name2', 'FullPath' => 'path2');
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->initialize(array($value1, $value2));
     $registryManager = $this->createMock('Model\\Registry\\RegistryManager');
     $registryManager->expects($this->once())->method('getValueDefinitions')->willReturn($resultSet);
     $registryManager->expects($this->never())->method('addValueDefinition');
     $registryManager->expects($this->exactly(2))->method('renameValueDefinition')->withConsecutive(array('name1', 'name1_new'), array('name2', 'name2'));
     $form = $this->getMockBuilder('Console\\Form\\ManageRegistryValues')->setMethods(array('getData'))->setConstructorArgs(array(null, array('config' => $this->_config, 'registryManager' => $registryManager)))->getMock();
     $form->expects($this->once())->method('getData')->willReturn($data);
     $form->init();
     $form->process();
 }
コード例 #24
0
<?php

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */
return array('router' => array('routes' => array('home' => array('type' => 'Zend\\Mvc\\Router\\Http\\Literal', 'options' => array('route' => '/', 'defaults' => array('controller' => 'Application\\Controller\\Index', 'action' => 'index'))), 'application' => array('type' => 'Literal', 'options' => array('route' => '/application', 'defaults' => array('__NAMESPACE__' => 'Application\\Controller', 'controller' => 'Index', 'action' => 'index')), 'may_terminate' => true, 'child_routes' => array('default' => array('type' => 'Segment', 'options' => array('route' => '/[:controller[/:action]]', 'constraints' => array('controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*'), 'defaults' => array())))), 'post' => array('type' => 'segment', 'options' => array('route' => '/post[/][:action][/page/:page][/:id]', 'constraints' => array('action' => '[a-zA-Z][a-zA-Z0-9_-]*', 'id' => '[0-9]+'), 'defaults' => array('controller' => 'Application\\Controller\\Post', 'action' => 'index'))))), 'service_manager' => array('abstract_factories' => array('Zend\\Cache\\Service\\StorageCacheAbstractServiceFactory', 'Zend\\Log\\LoggerAbstractServiceFactory'), 'aliases' => array('translator' => 'MvcTranslator'), 'factories' => array('Application\\Model\\PostTableGateway' => function ($sm) {
    $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
    $resultSetPrototype = new Zend\Db\ResultSet\ResultSet();
    $resultSetPrototype->setArrayObjectPrototype(new Application\Model\Post());
    $tableGateway = new Zend\Db\TableGateway\TableGateway('posts', $dbAdapter, null, $resultSetPrototype);
    $postTableGateway = new Application\Model\PostTableGateway($tableGateway);
    return $postTableGateway;
}, 'Cache' => function ($sm) {
    $config = $sm->get('Config');
    $cache = \Zend\Cache\StorageFactory::factory(array('adapter' => $config['cache']['adapter'], 'plugins' => array('exception_handler' => array('throw_exceptions' => false), 'Serializer'), 'options' => $config['cache']['options']));
    return $cache;
})), 'translator' => array('locale' => 'pt_BR', 'translation_file_patterns' => array(array('type' => 'phparray', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.php'))), 'controllers' => array('invokables' => array('Application\\Controller\\Index' => 'Application\\Controller\\IndexController', 'Application\\Controller\\Post' => 'Application\\Controller\\PostController')), 'view_manager' => array('display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array('layout/layout' => __DIR__ . '/../view/layout/layout.phtml', 'application/index/index' => __DIR__ . '/../view/application/index/index.phtml', 'error/404' => __DIR__ . '/../view/error/404.phtml', 'error/index' => __DIR__ . '/../view/error/index.phtml'), 'template_path_stack' => array(__DIR__ . '/../view')), 'console' => array('router' => array('routes' => array())));
コード例 #25
0
<?php

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */
return array('router' => array('routes' => array('home' => array('type' => 'Zend\\Mvc\\Router\\Http\\Literal', 'options' => array('route' => '/', 'defaults' => array('controller' => 'Application\\Controller\\Index', 'action' => 'index'))), 'application' => array('type' => 'Literal', 'options' => array('route' => '/application', 'defaults' => array('__NAMESPACE__' => 'Application\\Controller', 'controller' => 'Index', 'action' => 'index')), 'may_terminate' => true, 'child_routes' => array('default' => array('type' => 'Segment', 'options' => array('route' => '/[:controller[/:action]]', 'constraints' => array('controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*'), 'defaults' => array())))))), 'service_manager' => array('abstract_factories' => array('Zend\\Cache\\Service\\StorageCacheAbstractServiceFactory', 'Zend\\Log\\LoggerAbstractServiceFactory'), 'factories' => array('EntriesTableGateway' => function ($serviceManager) {
    $databaseAdapter = $serviceManager->get('Zend\\Db\\Adapter');
    $resultSet = new \Zend\Db\ResultSet\ResultSet();
    $resultSet->setArrayObjectPrototype(new \Application\Entity\Entry());
    $tableGateway = new \Zend\Db\TableGateway\TableGateway('entries', $databaseAdapter, null, $resultSet);
    return $tableGateway;
}, 'DatabaseTableStorage' => function ($serviceManager) {
    $storage = new \Application\Service\Storage\DatabaseTable($serviceManager->get('EntriesTableGateway'));
    return $storage;
}), 'invokables' => array('Application\\InputFilter\\EntryInputFilter' => 'Application\\InputFilter\\EntryInputFilter')), 'controllers' => array('factories' => array('Application\\Controller\\Index' => function ($controllerManager) {
    // We have to get the *actual* SM here as this is currently the controller manager derivative.
    $serviceManager = $controllerManager->getServiceLocator();
    $storage = $serviceManager->get('DatabaseTableStorage');
    $entryService = new \Application\Service\EntryService($storage);
    $inputFilter = $serviceManager->get('Application\\InputFilter\\EntryInputFilter');
    $controller = new \Application\Controller\IndexController();
    $controller->setEntryService($entryService);
    $controller->setEntryInputFilter($inputFilter);
    return $controller;
})), 'view_helpers' => array('invokables' => array('IntervalYearsDaysHours' => 'Application\\View\\Helper\\IntervalYearsDaysHours')), 'view_manager' => array('display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array('layout/layout' => __DIR__ . '/../view/layout/layout.phtml', 'application/index/index' => __DIR__ . '/../view/application/index/index.phtml', 'error/404' => __DIR__ . '/../view/error/404.phtml', 'error/index' => __DIR__ . '/../view/error/index.phtml'), 'template_path_stack' => array(__DIR__ . '/../view')), 'console' => array('router' => array('routes' => array())));
コード例 #26
0
 public function testIndexActionMessages()
 {
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->initialize(array());
     $this->_groupManager->expects($this->once())->method('getGroups')->willReturn($resultSet);
     $flashMessenger = $this->createMock('Zend\\View\\Helper\\FlashMessenger');
     $flashMessenger->method('__invoke')->with(null)->willReturnSelf();
     $flashMessenger->method('__call')->withConsecutive(array('getMessagesFromNamespace', array('error')), array('getMessagesFromNamespace', array('success')))->willReturnOnConsecutiveCalls(array('error'), array('success'));
     $this->getApplicationServiceLocator()->get('ViewHelperManager')->setService('flashMessenger', $flashMessenger);
     $this->_disableTranslator();
     $this->dispatch('/console/group/index/');
     $this->assertXpathQuery('//ul[@class="error"]/li[text()="error"]');
     $this->assertXpathQuery('//ul[@class="success"]/li[text()="success"]');
 }
コード例 #27
0
<?php

return array('router' => array('routes' => array('home' => array('type' => 'Zend\\Mvc\\Router\\Http\\Literal', 'options' => array('route' => '/', 'defaults' => array('controller' => 'CountryReferential\\Controller\\Index', 'action' => 'index'))), 'api_get_delete' => array('type' => 'segment', 'options' => array('route' => '/api/country[/:code]', 'defaults' => array('__NAMESPACE__' => 'CountryReferential\\Controller', 'controller' => 'Api', 'action' => 'index'))), 'api_admin' => array('type' => 'Literal', 'options' => array('route' => '/admin/api', 'defaults' => array('__NAMESPACE__' => 'CountryReferential\\Controller', 'controller' => 'Admin', 'action' => 'index')), 'may_terminate' => true, 'child_routes' => array('default' => array('type' => 'Segment', 'options' => array('route' => '/[:controller/[:action]]', 'constraints' => array('controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*'), 'defaults' => array())))), 'api_admin_delete' => array('type' => 'segment', 'options' => array('route' => '/admin/api/delete/[:code]', 'defaults' => array('__NAMESPACE__' => 'CountryReferential\\Controller', 'controller' => 'Admin', 'action' => 'delete'))), 'api_admin_update' => array('type' => 'segment', 'options' => array('route' => '/admin/api/update/[:code]', 'defaults' => array('__NAMESPACE__' => 'CountryReferential\\Controller', 'controller' => 'Admin', 'action' => 'countryUpdate'))), 'api_admin_create' => array('type' => 'segment', 'options' => array('route' => '/admin/api/create', 'defaults' => array('__NAMESPACE__' => 'CountryReferential\\Controller', 'controller' => 'Admin', 'action' => 'countryCreate'))))), 'service_manager' => array('abstract_factories' => array('Zend\\Cache\\Service\\StorageCacheAbstractServiceFactory', 'Zend\\Log\\LoggerAbstractServiceFactory'), 'factories' => array('translator' => 'Zend\\Mvc\\Service\\TranslatorServiceFactory', 'pays-table' => function ($sm) {
    $tableGateway = $sm->get('pays-table-gateway');
    $table = new \CountryReferential\Model\PaysTable($tableGateway);
    return $table;
}, 'pays-table-gateway' => function ($sm) {
    $dbAdapter = $sm->get('Zend\\db\\Adapter\\Adapter');
    $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
    $resultSetPrototype->setArrayObjectPrototype(new \CountryReferential\Model\Pays());
    return new \Zend\Db\TableGateway\TableGateway('pays', $dbAdapter, null, $resultSetPrototype);
})), 'translator' => array('locale' => 'en_US', 'translation_file_patterns' => array(array('type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo'))), 'controllers' => array('invokables' => array('CountryReferential\\Controller\\Index' => 'CountryReferential\\Controller\\IndexController', 'CountryReferential\\Controller\\Api' => 'CountryReferential\\Controller\\ApiController', 'CountryReferential\\Controller\\Admin' => 'CountryReferential\\Controller\\AdminController')), 'view_manager' => array('display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array('layout/layout' => __DIR__ . '/../view/layout/layout.phtml', 'layout/error' => __DIR__ . '/../view/layout/error.phtml', 'country-referencial/index/index' => __DIR__ . '/../view/country-referencial/index/index.phtml', 'country-referencial/api/index' => __DIR__ . '/../view/country-referencial/api/index.phtml', 'error/404' => __DIR__ . '/../view/error/404.phtml', 'error/index' => __DIR__ . '/../view/error/index.phtml'), 'template_path_stack' => array(__DIR__ . '/../view'), 'strategies' => array('ViewJsonStrategy')), 'console' => array('router' => array('routes' => array())));
コード例 #28
0
 public function testGroupsActionMember()
 {
     $groups = array(array('Id' => 1, 'Name' => 'group1'), array('Id' => 2, 'Name' => 'group2'));
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->initialize($groups);
     $memberships = array(1 => \Model\Client\Client::MEMBERSHIP_AUTOMATIC, 2 => \Model\Client\Client::MEMBERSHIP_ALWAYS);
     $formGroups = array('group1' => \Model\Client\Client::MEMBERSHIP_AUTOMATIC, 'group2' => \Model\Client\Client::MEMBERSHIP_ALWAYS);
     $form = $this->getApplicationServiceLocator()->get('FormElementManager')->get('Console\\Form\\GroupMemberships');
     $form->expects($this->once())->method('render')->will($this->returnValue('<form></form>'));
     $form->expects($this->once())->method('setData')->with(array('Groups' => $formGroups));
     $form->expects($this->once())->method('setAttribute')->with('action', '/console/client/managegroups/?id=1');
     $client = $this->createMock('Model\\Client\\Client');
     $client->expects($this->once())->method('getGroupMemberships')->with(\Model\Client\Client::MEMBERSHIP_ANY)->willReturn($memberships);
     $client->method('offsetGet')->will($this->returnValueMap(array(array('Id', 1))));
     $this->_clientManager->method('getClient')->willReturn($client);
     $this->_groupManager->expects($this->once())->method('getGroups')->with(null, null, 'Name')->willReturn($resultSet);
     $this->dispatch('/console/client/groups/?id=1');
     $this->assertResponseStatusCode(200);
     $this->assertXpathQueryContentContains('//h2', "\nGruppenmitgliedschaften\n");
     $this->assertXpathQueryContentContains('//tr[2]/td[1]/a[@href="/console/group/general/?name=group1"]', 'group1');
     $this->assertXpathQueryContentContains('//tr[2]/td[2]', "\nautomatisch\n");
     $this->assertXpathQueryContentContains('//tr[3]/td[1]/a[@href="/console/group/general/?name=group2"]', 'group2');
     $this->assertXpathQueryContentContains('//tr[3]/td[2]', "\nmanuell\n");
     $this->assertXpathQueryContentContains('//h2', "\nMitgliedschaften verwalten\n");
     $this->assertXPathQuery('//form');
 }
コード例 #29
0
ファイル: Module.php プロジェクト: nmnb18/Aufri.com
 public function getServiceConfig()
 {
     return array('factories' => array('UserTable' => function ($sm) {
         $tableGateway = $sm->get('UserTableGateway');
         $table = new Model\UserTable($tableGateway);
         return $table;
     }, 'UserTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('dbAdapter');
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Model\User());
         return new \Zend\Db\TableGateway\TableGateway(Model\UserTable::TABLE_NAME, $dbAdapter, null, $resultSetPrototype);
     }, 'ProductsTable' => function ($sm) {
         $tableGateway = $sm->get('ProductsTableGateway');
         $table = new Model\ProductsTable($tableGateway);
         return $table;
     }, 'ProductsTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('dbAdapter');
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Model\Products());
         return new \Zend\Db\TableGateway\TableGateway(Model\ProductsTable::TABLE_NAME, $dbAdapter, null, $resultSetPrototype);
     }, 'ShopkeeperTable' => function ($sm) {
         $tableGateway = $sm->get('ShopkeeperTableGateway');
         $table = new Model\ShopkeeperTable($tableGateway);
         return $table;
     }, 'ShopkeeperTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('dbAdapter');
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Model\Shopkeeper());
         return new \Zend\Db\TableGateway\TableGateway(Model\ShopkeeperTable::TABLE_NAME, $dbAdapter, null, $resultSetPrototype);
     }, 'AddressTable' => function ($sm) {
         $tableGateway = $sm->get('AddressTableGateway');
         $table = new Model\AddressTable($tableGateway);
         return $table;
     }, 'AddressTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('dbAdapter');
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Model\Address());
         return new \Zend\Db\TableGateway\TableGateway(Model\AddressTable::TABLE_NAME, $dbAdapter, null, $resultSetPrototype);
     }, 'CouponTable' => function ($sm) {
         $tableGateway = $sm->get('CouponTableGateway');
         $table = new Model\CouponTable($tableGateway);
         return $table;
     }, 'CouponTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('dbAdapter');
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Model\Coupon());
         return new \Zend\Db\TableGateway\TableGateway(Model\CouponTable::TABLE_NAME, $dbAdapter, null, $resultSetPrototype);
     }, 'OrderTable' => function ($sm) {
         $tableGateway = $sm->get('OrderTableGateway');
         $table = new Model\OrderTable($tableGateway);
         return $table;
     }, 'OrderTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('dbAdapter');
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Model\Order());
         return new \Zend\Db\TableGateway\TableGateway(Model\OrderTable::TABLE_NAME, $dbAdapter, null, $resultSetPrototype);
     }, 'UserRoleTable' => function ($sm) {
         $tableGateway = $sm->get('UserRoleTableGateway');
         $table = new Model\UserRoleTable($tableGateway);
         return $table;
     }, 'UserRoleTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('dbAdapter');
         $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Model\UserRole());
         return new \Zend\Db\TableGateway\TableGateway(Model\UserRoleTable::TABLE_NAME, $dbAdapter, null, $resultSetPrototype);
     }));
 }
コード例 #30
0
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */
return array('router' => array('routes' => array('home' => array('type' => 'Zend\\Mvc\\Router\\Http\\Literal', 'options' => array('route' => '/', 'defaults' => array('controller' => 'Application\\Controller\\Index', 'action' => 'index'))), 'list' => array('type' => 'literal', 'options' => array('route' => '/document/list', 'defaults' => array('controller' => 'Application\\Controller\\Document', 'action' => 'list')), 'may_terminate' => true), 'detail' => array('type' => 'segment', 'options' => array('route' => '/document/detail[/:doc]', 'constraints' => array('doc' => '[0-9]*'), 'defaults' => array('controller' => 'Application\\Controller\\Document', 'action' => 'detail')), 'may_terminate' => true), 'detail-error' => array('type' => 'segment', 'options' => array('route' => '/document/detail[/:doc][/:email]', 'constraints' => array('doc' => '[0-9]*', 'email' => '[0-1]'), 'defaults' => array('controller' => 'Application\\Controller\\Document', 'action' => 'detail')), 'may_terminate' => true), 'purchase' => array('type' => 'segment', 'options' => array('route' => '/document/purchase[/:doc]', 'constraints' => array('doc' => '[0-9]*'), 'defaults' => array('controller' => 'Application\\Controller\\Document', 'action' => 'purchase')), 'may_terminate' => true), 'application' => array('type' => 'Literal', 'options' => array('route' => '/application', 'defaults' => array('__NAMESPACE__' => 'Application\\Controller', 'controller' => 'Index', 'action' => 'index')), 'may_terminate' => true, 'child_routes' => array('default' => array('type' => 'Segment', 'options' => array('route' => '/[:controller[/:action]]', 'constraints' => array('controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*'), 'defaults' => array())))))), 'service_manager' => array('abstract_factories' => array('Zend\\Cache\\Service\\StorageCacheAbstractServiceFactory', 'Zend\\Log\\LoggerAbstractServiceFactory'), 'factories' => array('translator' => 'Zend\\Mvc\\Service\\TranslatorServiceFactory', 'DocumentTable' => function ($sm) {
    $tableGateway = $sm->get('DocumentTableGateway');
    $table = new \Application\Model\DocumentTable($tableGateway);
    return $table;
}, 'PurchaseTable' => function ($sm) {
    $tableGateway = $sm->get('PurchaseTableGateway');
    $table = new \Application\Model\PurchaseTable($tableGateway);
    return $table;
}, 'DocumentTableGateway' => function ($sm) {
    $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
    $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
    $resultSetPrototype->setArrayObjectPrototype(new \Application\Model\Document());
    //Set result set types (in this instance Document model type) and table name
    return new \Zend\Db\TableGateway\TableGateway('document', $dbAdapter, null, $resultSetPrototype);
}, 'PurchaseTableGateway' => function ($sm) {
    $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
    $resultSetPrototype = new \Zend\Db\ResultSet\ResultSet();
    //Set result set types (in this instance Document model type) and table name
    return new \Zend\Db\TableGateway\TableGateway('purchase', $dbAdapter, null, $resultSetPrototype);
}, 'DocumentTracker' => function () {
    //Returns the document tracker
    return new Application\Model\DocumentTracker($_COOKIE);
}, 'EmailValidator' => function () {
    //Returns an email address validator.
    $oValidator = new Zend\Validator\EmailAddress();
    return $oValidator;