Пример #1
0
 /**
  * Prepare an object that represents a Symphony section.
  *
  * @param	$section		Section|String		The section object or name to use.
  * @return	SymQueryResource
  */
 protected static function buildSection($section)
 {
     $resource = new SymQueryResource();
     if ($section instanceof Section) {
         $id = $section->get('id');
         if (isset(self::$section_cache[$id])) {
             $section = self::$section_cache[$id];
         }
         $resource->set('object', $section);
     } else {
         $id = is_int($section) ? $section : self::$sm->fetchIDFromHandle($section);
         if ($id > 0) {
             if (isset(self::$section_cache[$id])) {
                 $result = self::$section_cache[$id];
             } else {
                 $result = self::$sm->fetch($id);
             }
         }
         if (is_null($result)) {
             throw new Exception(sprintf('Unable to find section %s.', var_export($section, true)));
         }
         $resource->set('object', $result);
     }
     self::$section_cache[$id] = $resource->get('object');
     return $resource;
 }
Пример #2
0
 /**
  * Get all possible fields
  *
  * @throws	SymQueryException
  */
 public function getAll()
 {
     $section = $this->section->get('object');
     $this->selects = array();
     $fields = $section->fetchFields();
     if (is_array($fields)) {
         foreach ($fields as $field) {
             $resource = new SymQueryResource();
             $resource->set('object', $field);
             $this->selects[] = $resource;
         }
     }
     return $this;
 }