Exemple #1
0
 /**
  * Check if a given name is a valid column, and if it can be used in queries.
  *
  * @param  string $name
  * @param  array $contenttype
  * @param  bool $allowVariants
  * @return bool
  */
 private function isValidColumn($name, $contenttype, $allowVariants = false)
 {
     // Strip the minus in '-title' if allowed..
     if ($allowVariants) {
         if (strlen($name) > 0 && $name[0] == "-") {
             $name = substr($name, 1);
         }
         $name = $this->getFieldName($name);
     }
     // Check if the $name is in the contenttype's fields.
     if (isset($contenttype['fields'][$name])) {
         return true;
     }
     if (in_array($name, Content::getBaseColumns())) {
         return true;
     }
     return false;
 }
Exemple #2
0
 /**
  * Returns all field names for the given contenttype.
  *
  * @param string $contenttype The name of the contenttype.
  * @return string[] An array with all field definitions for the given
  *                  contenttype. This includes the base columns as well.
  */
 private function getAllFieldNames($contenttype)
 {
     $baseFields = \Bolt\Content::getBaseColumns();
     $definedFields = $this->app['config']->get("contenttypes/{$contenttype}/fields", []);
     $taxonomyFields = $this->getAllTaxonomies($contenttype);
     // Fields could be empty, although it's a rare case.
     if (!empty($definedFields)) {
         $definedFields = array_keys($definedFields);
     }
     $definedFields = array_merge($definedFields, $taxonomyFields);
     return array_merge($baseFields, $definedFields);
 }