Esempio n. 1
0
 public function install()
 {
     if (getenv('APP_ENV') === 'dev') {
         //develop only
         $tablesConfigDevelop = [TableManager::KEY_TABLES_CONFIGS => Store::$develop_tables_config];
         $tableManager = new TableManager($this->dbAdapter, $tablesConfigDevelop);
         $tableManager->rewriteTable(Store::PRODUCT_TABLE_NAME);
         $tableManager->rewriteTable(Store::IMAGE_TABLE_NAME);
         $tableManager->rewriteTable(Store::CATEGORY_TABLE_NAME);
         $tableManager->rewriteTable(Store::CATEGORY_PRODUCT_TABLE_NAME);
     }
 }
Esempio n. 2
0
 /**
  * {@inherit}
  *
  * {@inherit}
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->get('config');
     $this->tableName = isset($config[self::KEY][self::KEY_TABLE_NAME]) ? $config[self::KEY][self::KEY_TABLE_NAME] : (isset($options[self::KEY_TABLE_NAME]) ? $options[self::KEY_TABLE_NAME] : self::TABLE_NAME);
     $this->db = $container->has('db') ? $container->get('db') : null;
     if (is_null($this->db)) {
         throw new QueueException('Can\'t create db Adapter');
     }
     if ($container->has(TableManagerMysql::KEY_IN_CONFIG)) {
         $tableManager = $container->get(TableManagerMysql::KEY_IN_CONFIG);
     } else {
         $tableManager = new TableManagerMysql($this->db);
     }
     $hasPromiseStoreTable = $tableManager->hasTable($this->tableName);
     if (!$hasPromiseStoreTable) {
         $tableManager->rewriteTable($this->tableName, $this->promiseTableData);
     }
     $messagesStore = $container->has(Message\Factory\StoreFactory::KEY) ? $container->get(Message\Factory\StoreFactory::KEY) : null;
     if (is_null($messagesStore)) {
         throw new QueueException('Can\'t create Messages Store');
     }
     $promisesStore = $container->has(Promise\Factory\StoreFactory::KEY) ? $container->get(Promise\Factory\StoreFactory::KEY) : null;
     if (is_null($promisesStore)) {
         throw new QueueException('Can\'t create Promises Store');
     }
     return new Store($this->tableName, $this->db, $messagesStore, $promisesStore);
 }
 public function __invoke(ContainerInterface $container, $name, $requestedName)
 {
     $config = $container->get('config');
     $serviceConfig = $config[self::KEY_DATASTORE][self::KEY_ALL_NOTIFICATION];
     if (isset($serviceConfig[self::KEY_TABLE_GATEWAY])) {
         if ($container->has($serviceConfig[self::KEY_TABLE_GATEWAY])) {
             $tableGateway = $container->get($serviceConfig[self::KEY_TABLE_GATEWAY]);
         } else {
             throw new DataStoreException('Can\'t create ' . $serviceConfig[self::KEY_TABLE_GATEWAY]);
         }
     } else {
         if (isset($serviceConfig[self::KEY_TABLE_NAME])) {
             $tableName = $serviceConfig[self::KEY_TABLE_NAME];
             $dbServiceName = isset($serviceConfig[self::KEY_DB_ADAPTER]) ? $serviceConfig[self::KEY_DB_ADAPTER] : 'db';
             $db = $container->has($dbServiceName) ? $container->get($dbServiceName) : null;
             /*if ($container->has('TableManagerMysql')) {
                   $tableManager = $container->get('TableManagerMysql');
               } else {*/
             $tableManager = new TableManagerMysql($db);
             /*}*/
             $hasTable = $tableManager->hasTable($tableName);
             if (!$hasTable) {
                 $tableManager->rewriteTable($tableName, $this->tablePreferenceTableData);
             }
             $tableGateway = new TableGateway($tableName, $db);
         } else {
             throw new DataStoreException('There is not table name for ' . self::KEY_ALL_NOTIFICATION . 'in config \'dataStore\'');
         }
     }
     return new DbTable($tableGateway);
 }
 public function __invoke(ContainerInterface $container, $reqName, $requestedName)
 {
     $config = $container->get('config');
     $serviceConfig = $config[AbstractDataStoreFactory::KEY_DATASTORE][$requestedName];
     if (isset($serviceConfig[DbTableAbstractFactory::KEY_TABLE_GATEWAY])) {
         if ($container->has($serviceConfig[DbTableAbstractFactory::KEY_TABLE_GATEWAY])) {
             $tableGateway = $container->get($serviceConfig[DbTableAbstractFactory::KEY_TABLE_GATEWAY]);
         } else {
             throw new DataStoreException('Can\'t create ' . $serviceConfig[DbTableAbstractFactory::KEY_TABLE_GATEWAY]);
         }
     } else {
         if (isset($serviceConfig[DbTableAbstractFactory::KEY_TABLE_NAME])) {
             $tableName = $serviceConfig[DbTableAbstractFactory::KEY_TABLE_NAME];
             $dbServiceName = isset($serviceConfig[DbTableAbstractFactory::KEY_DB_ADAPTER]) ? $serviceConfig[DbTableAbstractFactory::KEY_DB_ADAPTER] : 'db';
             $db = $container->has($dbServiceName) ? $container->get($dbServiceName) : null;
             if ($container->has('TableManagerMysql')) {
                 $tableManager = $container->get('TableManagerMysql');
             } else {
                 $tableManager = new TableManagerMysql($db);
             }
             $hasTable = $tableManager->hasTable($tableName);
             if (!$hasTable) {
                 $tableManager->rewriteTable($tableName, $this->tablePreferenceTableData);
             }
             $tableGateway = new TableGateway($tableName, $db);
         } else {
             throw new DataStoreException('There is not table name for ' . $requestedName . 'in config \'dataStore\'');
         }
     }
     $class = (isset($serviceConfig[AbstractFactoryAbstract::KEY_CLASS]) and is_a($serviceConfig[AbstractFactoryAbstract::KEY_CLASS], DbTable::class, true)) ? $serviceConfig[AbstractFactoryAbstract::KEY_CLASS] : DbTable::class;
     return new $class($tableGateway);
 }
Esempio n. 5
0
 public function install()
 {
     if (getenv('APP_ENV') === 'dev') {
         //develop only
         $tablesConfigDevelop = [TableManager::KEY_TABLES_CONFIGS => array_merge(SysEntities::getTableConfigProdaction(), StoreCatalog::$develop_tables_config)];
         $tableManager = new TableManager($this->dbAdapter, $tablesConfigDevelop);
         $tableManager->rewriteTable(SysEntities::TABLE_NAME);
         $tableManager->rewriteTable(StoreCatalog::PRODUCT_TABLE_NAME);
         $tableManager->rewriteTable(StoreCatalog::TAG_TABLE_NAME);
         $tableManager->rewriteTable(StoreCatalog::MAINICON_TABLE_NAME);
         $tableManager->rewriteTable(StoreCatalog::MAIN_SPECIFIC_TABLE_NAME);
         $tableManager->rewriteTable(StoreCatalog::CATEGORY_TABLE_NAME);
         $tableManager->rewriteTable(StoreCatalog::PROP_LINKED_URL_TABLE_NAME);
         $tableManager->rewriteTable(StoreCatalog::PROP_PRODUCT_CATEGORY_TABLE_NAME);
         $tableManager->rewriteTable(StoreCatalog::PROP_TAG_TABLE_NAME);
     } else {
         $tablesConfigProdaction = [TableManager::KEY_TABLES_CONFIGS => SysEntities::getTableConfigProdaction()];
         $tableManager = new TableManager($this->dbAdapter, $tablesConfigProdaction);
         $tableManager->createTable(SysEntities::TABLE_NAME);
     }
 }
Esempio n. 6
0
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->get('config');
     $tableName = isset($config[self::KEY][self::KEY_TABLE_NAME]) ? $config[self::KEY][self::KEY_TABLE_NAME] : (isset($options[self::KEY_TABLE_NAME]) ? $options[self::KEY_TABLE_NAME] : self::TABLE_NAME);
     $db = $container->has('db') ? $container->get('db') : null;
     if (is_null($db)) {
         throw new UnexpectedValueException('Can\'t create db Adapter');
     }
     if ($container->has(TableManagerMysql::KEY_IN_CONFIG)) {
         $tableManager = $container->get(TableManagerMysql::KEY_IN_CONFIG);
     } else {
         $tableManager = new TableManagerMysql($db);
     }
     $hasPromiseStoreTable = $tableManager->hasTable($tableName);
     if (!$hasPromiseStoreTable) {
         $tableManager->rewriteTable($tableName, $this->taskStoreData);
     }
     return new Store($tableName, $db);
 }