Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  *
  * @param   bool $allFields         Allows to show all the fields
  * @param   bool $recursive         Convert this method in recursive
  * @param   bool $convertToDatabase Convert property names to database
  *
  * @return stdClass
  */
 public function toObject($allFields = false, $recursive = false, $convertToDatabase = true)
 {
     $object = parent::toObject($allFields, $recursive, $convertToDatabase);
     if (!empty($this->group) && $convertToDatabase) {
         $object->group_id = $this->group->getId();
     }
     return $object;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * @param   bool $allFields         Allows to show all the fields
  * @param   bool $recursive         Convert this method in recursive
  * @param   bool $convertToDatabase Convert property names to database
  *
  * @return stdClass
  */
 public function toObject($allFields = false, $recursive = false, $convertToDatabase = true)
 {
     $object = parent::toObject($allFields, $recursive, $convertToDatabase);
     if (!empty($this->group) && $convertToDatabase) {
         $object->group_id = $this->group->getId();
     }
     // If it's an array, let's json it!
     if (is_array($this->primaryKey) && $convertToDatabase) {
         $object->primary_key = json_encode($this->primaryKey);
     }
     return $object;
 }
Ejemplo n.º 3
0
 /**
  * Get all the tables of the component that matches with the Joomla naming convention.
  *
  * @param   NenoContentElementGroup $group             Component name
  * @param   string                  $tablePattern      Table Pattern
  * @param   bool                    $includeDiscovered Included tables that have been discovered already
  *
  * @return array
  */
 public static function getComponentTables(NenoContentElementGroup $group, $tablePattern = null, $includeDiscovered = true)
 {
     /* @var $db NenoDatabaseDriverMysqlx */
     $db = JFactory::getDbo();
     $tables = $db->getComponentTables($tablePattern === null ? $group->getGroupName() : $tablePattern);
     $result = array();
     for ($i = 0; $i < count($tables); $i++) {
         // Get Table name
         $tableName = self::unifyTableName($tables[$i]);
         $table = null;
         $tablesIgnored = self::getDoNotTranslateTables();
         if (!in_array($tableName, $tablesIgnored)) {
             if (!self::isTableAlreadyDiscovered($tableName)) {
                 // Create an array with the table information
                 $tableData = array('tableName' => $tableName, 'primaryKey' => $db->getPrimaryKey($tableName), 'translate' => 1, 'group' => $group);
                 // Create ContentElement object
                 $table = new NenoContentElementTable($tableData);
                 // Get all the columns a table contains
                 $fields = $db->getTableColumns($table->getTableName());
                 foreach ($fields as $fieldName => $fieldType) {
                     $fieldData = array('fieldName' => $fieldName, 'fieldType' => $fieldType, 'translate' => NenoContentElementField::isTranslatableType($fieldType), 'table' => $table);
                     $field = new NenoContentElementField($fieldData);
                     $table->addField($field);
                 }
             } elseif ($includeDiscovered) {
                 $table = NenoContentElementTable::load(array('table_name' => $tableName, 'group_id' => $group->getId()));
             }
         }
         if (!empty($table)) {
             $result[] = $table;
         }
     }
     return $result;
 }