コード例 #1
0
ファイル: TableGateway.php プロジェクト: kalelc/inventory
 public function __construct($table, AdapterInterface $adapter, $features = null, ResultSetInterface $resultSetPrototype = null)
 {
     if (!(is_string($table) || $table instanceof TableIdentifier)) {
         throw new \InvalidArgumentException('Table name must be a string or an instance of Zend\\Db\\Sql\\TableIdentifier');
     }
     $this->table = $table;
     $this->adapter = $adapter;
     if ($features !== null) {
         if ($features instanceof AbstractFeature) {
             $features = array($features);
         }
         if (is_array($features)) {
             $this->featureSet = new FeatureSet($features);
         } elseif ($features instanceof FeatureSet) {
             $this->featureSet = $features;
         } else {
             throw new \InvalidArgumentException('TableGateway expects $feature to be an instance of an AbstractFeature or a FeatureSet, or an array of AbstractFeatures');
         }
     } else {
         $this->featureSet = new FeatureSet();
     }
     $resources = preg_replace('/(?<!^)([A-Z])/', '-\\1', explode("\\", get_class($resultSetPrototype->getArrayObjectPrototype()))[2]);
     $this->tableName = strtolower(str_replace("-", "_", $resources));
     $this->resultSetPrototype = $resultSetPrototype ?: new ResultSet();
     $this->initialize();
 }
コード例 #2
0
ファイル: MongoGateway.php プロジェクト: pasechnik/mongozend
 /**
  * @return mixed
  */
 public function model()
 {
     return clone $this->resultSetPrototype->getArrayObjectPrototype();
 }