Ejemplo n.º 1
0
 /**
  * @param FREST\Resource $resource
  * @param array $readSettings
  * @return array|NULL
  */
 protected function generateTableSpecs($resource, $readSettings)
 {
     $tableSpecs = array();
     /** @var Setting\Read $readSetting */
     foreach ($readSettings as $readSetting) {
         $alias = $readSetting->getAlias();
         $field = $resource->getFieldForAlias($alias);
         $table = $resource->getTableForField($field);
         if ($readSetting instanceof Setting\FieldRead || $readSetting instanceof Setting\SingularResourceRead) {
             $tableAbbvr = $this->getTableAbbreviation($table);
             $tableSpec = new Spec\Table($table, $tableAbbvr);
             $tableSpecs[$table] = $tableSpec;
         }
     }
     if (count($tableSpecs) > 0) {
         return $tableSpecs;
     }
     return NULL;
 }
Ejemplo n.º 2
0
 /**
  * @param FREST\Resource $resource
  * @param array $createSpecs
  * @return array|NULL
  */
 protected function generateTableCreateSpecs($resource, $createSpecs)
 {
     $tableCreateSpecs = array();
     $tablesAndTheirCreateSpecs = array();
     /** @var Spec\Create $createSpec */
     foreach ($createSpecs as $createSpec) {
         $alias = $createSpec->getAlias();
         $field = $resource->getFieldForAlias($alias);
         $table = $resource->getTableForField($field);
         $tablesAndTheirCreateSpecs[$table][] = $createSpec;
     }
     foreach ($tablesAndTheirCreateSpecs as $table => $createSpecs) {
         $tableCreateSpec = new Spec\TableCreate($table, $createSpecs);
         $tableCreateSpecs[] = $tableCreateSpec;
     }
     if (count($tableCreateSpecs) > 0) {
         return $tableCreateSpecs;
     }
     return NULL;
 }
Ejemplo n.º 3
0
 /**
  * @param FREST\Resource $resource
  * @param array $updateSpecs
  * @return array|NULL
  */
 protected function generateTableUpdateSpecs($resource, $updateSpecs)
 {
     $tableUpdateSpecs = array();
     $tablesAndTheirUpdateSpecs = array();
     /** @var Spec\Update $updateSpec */
     foreach ($updateSpecs as $updateSpec) {
         $alias = $updateSpec->getAlias();
         $field = $resource->getFieldForAlias($alias);
         $table = $resource->getTableForField($field);
         $tablesAndTheirUpdateSpecs[$table][] = $updateSpec;
     }
     foreach ($tablesAndTheirUpdateSpecs as $table => $updateSpecs) {
         $tableUpdateSpec = new Spec\TableUpdate($table, $updateSpecs);
         $tableUpdateSpecs[] = $tableUpdateSpec;
     }
     return $tableUpdateSpecs;
 }