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


PHP ClassLoader::classExists方法代码示例

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


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

示例1: actionNew

 /**
  * Create a new pagetype
  */
 public function actionNew()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("manage/elementtypes/new"));
     $field = $form->newField();
     $field->setLegend('New element type');
     $element = $field->newElement('TextInput', 'name');
     $element->setLabel('Name');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\Safe($element));
     $element = $field->newElement('TextInput', 'class');
     $element->setLabel('Class');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $form->newButton('submit', 'Add Element');
     $this->setVar('form', $form);
     if ($input = $form->processInput($this->post)) {
         //class_exists causes doctrine to try and load the class which fails so we look first if doctrine can load it and then
         //if that fails we use class exists with no auto_load so it just looks in existing includes
         if (\Doctrine\Common\ClassLoader::classExists(ltrim($input->get('class'), '\\')) or class_exists($input->get('class'), false)) {
             $elementType = new \Jazzee\Entity\ElementType();
             $elementType->setName($input->get('name'));
             $elementType->setClass($input->get('class'));
             $this->addMessage('success', $input->get('name') . " saved.");
             $this->_em->persist($elementType);
             $this->redirectPath('manage/elementtypes');
         } else {
             $this->addMessage('error', "That is not a valid class name.  The class must eithier by loadable by a Doctrine::classLoader registered in the autoload stack or already be included.");
         }
     }
 }
开发者ID:Jazzee,项目名称:Jazzee,代码行数:34,代码来源:manage_elementtypes.php

示例2: testClassExists

 public function testClassExists()
 {
     $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\\ClassD'));
     $badLoader = function ($className) {
         require __DIR__ . '/ClassLoaderTest/ClassD.php';
         return true;
     };
     spl_autoload_register($badLoader);
     $this->assertTrue(ClassLoader::classExists('ClassLoaderTest\\ClassD'));
     spl_autoload_unregister($badLoader);
 }
开发者ID:GMBN,项目名称:ZF2---DoctrineModule---ManyToOne-,代码行数:11,代码来源:ClassLoaderTest.php

示例3: testClassExistsWhenLoaderIsProtected

 public function testClassExistsWhenLoaderIsProtected()
 {
     require_once __DIR__ . '/ClassLoaderTest/ExternalLoader.php';
     // Test static call
     \ClassLoaderTest\ExternalLoader::registerStatic();
     $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\\Class\\That\\Does\\Not\\Exist'));
     \ClassLoaderTest\ExternalLoader::unregisterStatic();
     // Test object
     $loader = new \ClassLoaderTest\ExternalLoader();
     $loader->register();
     $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\\Class\\That\\Does\\Not\\Exist'));
     $loader->unregister();
 }
开发者ID:Dren-x,项目名称:mobitnew,代码行数:13,代码来源:ClassLoaderTest.php

示例4: testClassExistsWithSilentAutoloader

 public function testClassExistsWithSilentAutoloader()
 {
     $test = $this;
     $silentLoader = function ($className) use($test) {
         $test->assertSame('ClassLoaderTest\\ClassE', $className);
         require __DIR__ . '/ClassLoaderTest/ClassE.php';
     };
     $additionalLoader = function () use($test) {
         $test->fail('Should not call this loader, class was already loaded');
     };
     $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\\ClassE'));
     spl_autoload_register($silentLoader);
     spl_autoload_register($additionalLoader);
     $this->assertTrue(ClassLoader::classExists('ClassLoaderTest\\ClassE'));
     spl_autoload_unregister($additionalLoader);
     spl_autoload_unregister($silentLoader);
 }
开发者ID:chinazan,项目名称:zzcrm,代码行数:17,代码来源:ClassLoaderTest.php

示例5: validateClassMapping

 /**
  * Finalize the mapping and make sure that it is consistent.
  *
  * @throws MappingException if inconsistencies are discovered.
  */
 public function validateClassMapping()
 {
     // associative array fields need a separate property to store the keys.
     // make sure that generated or specified name does not collide with an
     // existing mapping.
     $assocFields = array();
     foreach ($this->fieldMappings as $fieldName) {
         $mapping = $this->mappings[$fieldName];
         if (empty($mapping['assoc'])) {
             continue;
         }
         if (isset($this->mappings[$mapping['assoc']])) {
             throw MappingException::assocOverlappingFieldDefinition($this->name, $fieldName, $mapping['assoc']);
         }
         if (!empty($assocFields[$mapping['assoc']])) {
             throw MappingException::assocOverlappingAssocDefinition($this->name, $fieldName, $assocFields[$mapping['assoc']]);
         }
         $assocFields[$mapping['assoc']] = $fieldName;
     }
     if (!empty($this->versionNameField) && !$this->versionable) {
         throw new MappingException(sprintf("You cannot use the @VersionName annotation on the non-versionable document %s (field = %s)", $this->name, $this->versionNameField));
     }
     if (!empty($this->versionCreatedField) && !$this->versionable) {
         throw new MappingException(sprintf("You cannot use the @VersionCreated annotation on the non-versionable document %s (field = %s)", $this->name, $this->versionCreatedField));
     }
     if (count($this->translatableFields)) {
         if (!isset($this->localeMapping)) {
             throw new MappingException("You must define a locale mapping for translatable document '" . $this->name . "'");
         }
     }
     // we allow mixed referrers on non-referenceable documents. maybe the mix:referenceable is just not mapped
     if (count($this->referrersMappings)) {
         if (!$this->referenceable) {
             throw new MappingException('You can not have referrers mapped on document "' . $this->name . '" as the document is not referenceable');
         }
         foreach ($this->referrersMappings as $referrerName) {
             $mapping = $this->mappings[$referrerName];
             // only a santiy check with reflection. otherwise we could run into endless loops
             if (!ClassLoader::classExists($mapping['referringDocument'])) {
                 throw new MappingException(sprintf('Invalid referrer mapping on document "%s" for field "%s": The referringDocument class "%s" does not exist', $this->name, $mapping['fieldName'], $mapping['referringDocument']));
             }
             $reflection = new ReflectionClass($mapping['referringDocument']);
             if (!$reflection->hasProperty($mapping['referencedBy'])) {
                 throw new MappingException(sprintf('Invalid referrer mapping on document "%s" for field "%s": The referringDocument "%s" has no property "%s"', $this->name, $mapping['fieldName'], $mapping['referringDocument'], $mapping['referencedBy']));
             }
         }
     }
     $this->validateIdentifier();
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:54,代码来源:ClassMetadata.php

示例6: validateAssocations

 /**
  * Validate association targets actually exist.
  *
  * @throws MappingException
  * @return void
  */
 public function validateAssocations()
 {
     foreach ($this->associationMappings as $mapping) {
         if (!ClassLoader::classExists($mapping['targetEntity'])) {
             throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']);
         }
     }
 }
开发者ID:alexanderwsp-git,项目名称:columbus,代码行数:14,代码来源:ClassMetadataInfo.php

示例7: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $pdf_tool = $this->config('printable.settings')->get('pdf_tool');
     \Drupal::service('config.factory')->getEditable('printable.settings')->set('pdf_tool', $form_state->getValue('print_pdf_pdf_tool'))->set('save_pdf', $form_state->getValue('print_pdf_content_disposition'))->set('paper_size', (string) $form_state->getValue('print_pdf_paper_size'))->set('page_orientation', $form_state->getValue('print_pdf_page_orientation'))->set('pdf_location', $form_state->getValue('print_pdf_filename'))->save();
     if (ClassLoader::classExists('mikehaertl\\wkhtmlto\\Pdf') && $pdf_tool == 'wkhtmltopdf') {
         \Drupal::service('config.factory')->getEditable('printable.settings')->set('path_to_binary', $form_state->getValue('path_to_binary'))->save();
     }
 }
开发者ID:gerbreown1,项目名称:calvaryfree,代码行数:11,代码来源:FormatConfigurationFormPdf.php

示例8: actionNew

 /**
  * Create a new pagetype
  */
 public function actionNew()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("manage/paymenttypes/new"));
     $field = $form->newField();
     $element = $field->newElement('TextInput', 'className');
     $element->setLabel('Class');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $form->newButton('submit', 'Next');
     if (isset($this->post['className'])) {
         $className = $this->post['className'];
         if (!isset($this->post['newtypeform'])) {
             $this->post = array();
             //reset $_POST so we don't try and validate the empty form
         }
         //class_exists causes doctrine to try and load the class which fails so we look first if doctrine can load it and then
         //if that fails we use class exists with no auto_load so it just looks in existing includes
         if (\Doctrine\Common\ClassLoader::classExists(ltrim($className, '\\')) or class_exists($className, false)) {
             $paymentType = new \Jazzee\Entity\PaymentType();
             $paymentClass = new $className($paymentType, $this);
             $form = $paymentClass->getSetupForm();
             $form->setAction($this->path("manage/paymenttypes/new"));
             $form->newHiddenElement('className', $className);
             $form->newHiddenElement('newtypeform', true);
         } else {
             $form->getElementByName('className')->addMessage('That is not a valid class name.  The class must eithier by loadable by a Doctrine::classLoader in the autoload stack or already be included.');
         }
     }
     $this->setVar('form', $form);
     if ($input = $form->processInput($this->post)) {
         if ($input->get('newtypeform')) {
             if ($this->_em->getRepository('Jazzee\\Entity\\PaymentType')->findBy(array('name' => $input->get('name')))) {
                 $form->getElementByName('name')->addMessage('That payment name has already been used.');
                 return false;
             }
             $paymentClass->setup($input);
             $this->_em->persist($paymentType);
             foreach ($paymentType->getVariables() as $var) {
                 $this->_em->persist($var);
             }
             $this->addMessage('success', $input->get('name') . ' saved.');
             $this->redirectPath('manage/paymenttypes');
         }
     }
 }
开发者ID:Jazzee,项目名称:Jazzee,代码行数:49,代码来源:manage_paymenttypes.php


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