当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadata::isNullable方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadata::isNullable方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::isNullable方法的具体用法?PHP ClassMetadata::isNullable怎么用?PHP ClassMetadata::isNullable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::isNullable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFieldIsNullable

 public function testFieldIsNullable()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     // Explicit Nullable
     $cm->mapField(array('fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50));
     $this->assertTrue($cm->isNullable('status'));
     // Explicit Not Nullable
     $cm->mapField(array('fieldName' => 'username', 'nullable' => false, 'type' => 'string', 'length' => 50));
     $this->assertFalse($cm->isNullable('username'));
     // Implicit Not Nullable
     $cm->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 50));
     $this->assertFalse($cm->isNullable('name'), "By default a field should not be nullable.");
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:13,代码来源:ClassMetadataTest.php

示例2: testFieldIsNullable

 public function testFieldIsNullable()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     // Explicit Nullable
     $cm->mapField(array('fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50));
     $this->assertTrue($cm->isNullable('status'));
     // Explicit Not Nullable
     $cm->mapField(array('fieldName' => 'username', 'nullable' => false, 'type' => 'string', 'length' => 50));
     $this->assertFalse($cm->isNullable('username'));
     // Implicit Not Nullable
     $cm->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 50));
     $this->assertFalse($cm->isNullable('name'), "By default a field should not be nullable.");
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:14,代码来源:ClassMetadataTest.php

示例3: __construct

 public function __construct(\Symforce\AdminBundle\Compiler\Generator\AnnotationCache $cache, $bundle_name, ClassMetadata $meta, Generator $gen)
 {
     $this->cache = $cache;
     $this->bundle_name = $bundle_name;
     $this->class_name = $cache->class_name;
     $this->reflection = $meta->getReflectionClass();
     $this->generator = $gen;
     $this->orm_metadata = $meta;
     if ($meta->isIdentifierComposite) {
         // @TODO add Composite route handle
     } else {
         $this->property_id_name = $meta->getSingleIdentifierFieldName();
     }
     $this->setMyPropertie($cache->class_annotations['Symforce\\AdminBundle\\Compiler\\Annotation\\Entity']);
     if (!$this->name) {
         $this->name = strtolower(preg_replace('/\\W/', '_', $this->class_name));
     }
     $this->template = $this->name . '.admin.html.twig';
     $this->_template_path = $this->generator->getParameter('kernel.root_dir') . '/Resources/views/' . $this->template;
     if (null === $this->_final_template) {
         $tempalte = $this->bundle_name . ':' . basename(str_replace('\\', '\\/', $this->class_name)) . ':admin.macro.html.twig';
         try {
             $this->generator->loadTwigTemplatePath($tempalte);
             $this->_final_template = $tempalte;
         } catch (\InvalidArgumentException $e) {
         }
     }
     $compile_class_name = ucfirst($this->camelize($this->name));
     $this->_compile_class_name = 'Symforce\\AdminCache\\' . $compile_class_name . '\\Admin' . $compile_class_name;
     if (null === $this->tr_domain) {
         $this->tr_domain = $this->bundle_name;
     }
     $this->sf_domain = $gen->getSymforceDomain();
     if (isset($cache->class_annotations[self::ANNOT_TREE_CLASS])) {
         // not work for yml/xml,  because the private stof_doctrine_extensions.listener.tree service
         $tree_annot_len = strlen(self::ANNOT_TREE_CLASS);
         $this->tree = array();
         foreach ($cache->propertie_annotations as $property_name => $as) {
             foreach ($as as $annot_class => &$value) {
                 if (0 === strpos($annot_class, self::ANNOT_TREE_CLASS)) {
                     $tree_config_key = strtolower(substr($annot_class, $tree_annot_len));
                     $this->tree[$tree_config_key] = $property_name;
                 }
             }
         }
         if (!isset($this->tree['parent'])) {
             $this->throwError("missing @%sParent", self::ANNOT_TREE_CLASS);
         }
         if (!isset($this->tree['root'])) {
             $this->throwError("missing @%sRoot", self::ANNOT_TREE_CLASS);
         }
     }
     if (isset($cache->class_annotations[self::ANNOT_TOSTR_CLASS])) {
         \Dev::dump($cache->class_annotations[self::ANNOT_TOSTR_CLASS]);
         exit;
     }
     if (isset($cache->class_annotations[self::ANNOT_TREE_LEAF_CLASS])) {
         \Dev::dump($cache->class_annotations[self::ANNOT_TREE_LEAF_CLASS]);
         exit;
     }
     foreach ($cache->propertie_annotations as $property_name => $as) {
         if (isset($as[self::ANNOT_SLUG_CLASS])) {
             if ($this->property_slug_name) {
                 $this->throwError("slug property duplicate(%s, %s)", $this->property_slug_name, $property_name);
             }
             $this->property_slug_name = $property_name;
             $this->property_slug_unique = $meta->isUniqueField($property_name);
             $this->property_slug_nullable = $meta->isNullable($property_name);
         }
         if (isset($as[self::ANNOT_TOSTR_CLASS])) {
             if ($this->property_value_name) {
                 $this->throwError("@ToString(%s) is conflict with @ToString(%s)", $property_name, $this->property_value_name);
             }
             $this->property_value_name = $property_name;
         }
         if (isset($as[self::ANNOT_TREE_LEAF_CLASS])) {
             if (!$this->tree) {
                 $this->throwError("use @%s(%s) without @%s", self::ANNOT_TREE_LEAF_CLASS, $property_name, self::ANNOT_TREE_CLASS);
             }
             if (isset($this->tree['leaf'])) {
                 $this->throwError("@ToString(%s) is conflict with %s", self::ANNOT_TREE_LEAF_CLASS, $property_name, $this->tree['leaf']);
             }
             $this->tree['leaf'] = $property_name;
         }
         if (isset($as[Page::PAGE_ANNOT_CLASS])) {
             if ($this->page) {
                 $this->throwError("page property duplicate(%s, %s)", $this->page->pege_property, $property_name);
             }
             $this->page = new Page($this, $property_name, $as[Page::PAGE_ANNOT_CLASS]);
         }
         if (isset($as[Owner::OWNER_ANNOT_CLASS])) {
             if ($this->owner) {
                 $this->throwError("owner property duplicate(%s, %s)", $this->owner->owner_property, $property_name);
             }
             $this->owner = new Owner($this, $property_name, $as[Owner::OWNER_ANNOT_CLASS]);
         }
     }
     if (isset($cache->class_annotations[self::ANNOT_WORKFLOW_CLASS])) {
         $this->workflow = new Workflow($this, $cache->class_annotations[self::ANNOT_WORKFLOW_CLASS]);
     }
//.........这里部分代码省略.........
开发者ID:symforce,项目名称:symforce-admin,代码行数:101,代码来源:Entity.php

示例4: determineFromColumns

 private function determineFromColumns(ClassMetadata $classMetadata)
 {
     $out = [];
     /** @var Column $column */
     foreach ($classMetadata->getFieldNames() as $fieldName) {
         $fieldMapping = [];
         try {
             $fieldMapping = $classMetadata->getFieldMapping($fieldName);
         } catch (MappingException $e) {
             $fieldMapping['type'] = 'undefined';
         }
         $columnName = $classMetadata->getColumnName($fieldName);
         $type = $classMetadata->getTypeOfField($fieldName);
         $isNullable = $classMetadata->isNullable($fieldName);
         if (strtolower($type) === 'enum') {
             $out[$columnName] = ['type' => IColumnStructure::ENUM];
             $enum = $fieldMapping['columnDefinition'];
             $options = str_getcsv(str_replace('enum(', '', substr($enum, 0, strlen($enum) - 1)), ',', "'");
             $out[$columnName]['values'] = [];
             foreach ($options as $option) {
                 $out[$columnName]['values'][] = $option;
             }
         } else {
             switch ($type) {
                 case Type::STRING:
                 case Type::TEXT:
                     $out[$columnName] = ['type' => IColumnStructure::TEXT];
                     break;
                 case Type::INTEGER:
                 case Type::FLOAT:
                 case Type::SMALLINT:
                 case Type::BIGINT:
                 case Type::DECIMAL:
                     $out[$columnName] = ['type' => IColumnStructure::NUMBER];
                     break;
                 case Type::DATETIME:
                 case Type::DATETIMETZ:
                 case Type::DATE:
                 case Type::TIME:
                     $out[$columnName] = ['type' => IColumnStructure::DATE];
                     break;
                 case Type::BOOLEAN:
                     $out[$columnName] = ['type' => IColumnStructure::BOOL];
                     break;
             }
         }
         if (isset($out[$columnName])) {
             $out[$columnName]['nullable'] = $isNullable;
         }
     }
     return $out;
 }
开发者ID:mesour,项目名称:sources,代码行数:52,代码来源:DoctrineSource.php


注:本文中的Doctrine\ORM\Mapping\ClassMetadata::isNullable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。