• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP SS_ClassLoader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中SS_ClassLoader的典型用法代码示例。如果您正苦于以下问题:PHP SS_ClassLoader类的具体用法?PHP SS_ClassLoader怎么用?PHP SS_ClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: testGetItemPath

	function testGetItemPath() {
		$ds = DIRECTORY_SEPARATOR;
		$loader = new SS_ClassLoader();
		
		$loader->pushManifest($this->testManifest1);
		$this->assertEquals(
			$this->baseManifest1 . $ds . 'module' . $ds . 'classes' . $ds . 'ClassA.php',
			$loader->getItemPath('ClassA')
		);
		$this->assertEquals(
			false,
			$loader->getItemPath('UnknownClass')
		);
		$this->assertEquals(
			false,
			$loader->getItemPath('OtherClassA')
		);
		
		$loader->pushManifest($this->testManifest2);
		$this->assertEquals(
			false,
			$loader->getItemPath('ClassA')
		);
		$this->assertEquals(
			false,
			$loader->getItemPath('UnknownClass')
		);
		$this->assertEquals(
			$this->baseManifest2 . $ds . 'module' . $ds . 'classes' . $ds . 'OtherClassA.php',
			$loader->getItemPath('OtherClassA')
		);
	}
开发者ID:redema,项目名称:sapphire,代码行数:32,代码来源:ClassLoaderTest.php


示例2: testGetItemPath

 public function testGetItemPath()
 {
     $loader = new SS_ClassLoader();
     $loader->pushManifest($this->testManifest1);
     $this->assertEquals(realpath($this->baseManifest1 . '/module/classes/ClassA.php'), realpath($loader->getItemPath('ClassA')));
     $this->assertEquals(false, $loader->getItemPath('UnknownClass'));
     $this->assertEquals(false, $loader->getItemPath('OtherClassA'));
     $loader->pushManifest($this->testManifest2);
     $this->assertEquals(false, $loader->getItemPath('ClassA'));
     $this->assertEquals(false, $loader->getItemPath('UnknownClass'));
     $this->assertEquals(realpath($this->baseManifest2 . '/module/classes/OtherClassA.php'), realpath($loader->getItemPath('OtherClassA')));
 }
开发者ID:normann,项目名称:sapphire,代码行数:12,代码来源:ClassLoaderTest.php


示例3: executeInSubprocess

 function executeInSubprocess($includeStderr = false)
 {
     // Get the path to the ErrorControlChain class
     $classpath = SS_ClassLoader::instance()->getItemPath('ErrorControlChain');
     $suppression = $this->suppression ? 'true' : 'false';
     // Start building a PHP file that will execute the chain
     $src = '<' . "?php\nrequire_once '{$classpath}';\n\n\$chain = new ErrorControlChain();\n\n\$chain->setSuppression({$suppression});\n\n\$chain\n";
     // For each step, use reflection to pull out the call, stick in the the PHP source we're building
     foreach ($this->steps as $step) {
         $func = new ReflectionFunction($step['callback']);
         $source = file($func->getFileName());
         $start_line = $func->getStartLine() - 1;
         $end_line = $func->getEndLine();
         $length = $end_line - $start_line;
         $src .= implode("", array_slice($source, $start_line, $length)) . "\n";
     }
     // Finally add a line to execute the chain
     $src .= "->execute();";
     // Now stick it in a temporary file & run it
     $codepath = TEMP_FOLDER . '/ErrorControlChainTest_' . sha1($src) . '.php';
     if ($includeStderr) {
         $null = '&1';
     } else {
         $null = is_writeable('/dev/null') ? '/dev/null' : 'NUL';
     }
     file_put_contents($codepath, $src);
     exec("php {$codepath} 2>{$null}", $stdout, $errcode);
     unlink($codepath);
     return array(implode("\n", $stdout), $errcode);
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:30,代码来源:ErrorControlChainTest.php


示例4: use_test_manifest

 /**
  * Pushes a class and template manifest instance that include tests onto the
  * top of the loader stacks.
  */
 public static function use_test_manifest()
 {
     $classManifest = new SS_ClassManifest(BASE_PATH, true, isset($_GET['flush']));
     SS_ClassLoader::instance()->pushManifest($classManifest);
     SapphireTest::set_test_class_manifest($classManifest);
     SS_TemplateLoader::instance()->pushManifest(new SS_TemplateManifest(BASE_PATH, true, isset($_GET['flush'])));
 }
开发者ID:normann,项目名称:sapphire,代码行数:11,代码来源:TestRunner.php


示例5: __construct

 public function __construct($allowed_types = array())
 {
     $this->addComponent(new GridFieldAddNewMultiClass());
     $this->addComponent(new GridFieldToolbarHeader());
     $this->addComponent(new GridFieldTitleHeader());
     $this->addComponent(new GridFieldEditableColumns());
     $this->addComponent(new GridFieldEditButton());
     $this->addComponent(new GridFieldDeleteAction(false));
     $this->addComponent(new GridFieldDetailForm());
     // Multi-Class Add Button
     /////////////////////////
     $classes = array();
     if (empty($allowed_types)) {
         $allowed_types = SS_ClassLoader::instance()->getManifest()->getDescendantsOf('FlexiFormHandler');
     }
     foreach ($allowed_types as $className) {
         $class = singleton($className);
         $classes[$className] = "{$class->Label()}";
     }
     $component = $this->getComponentByType('GridFieldAddNewMultiClass');
     $component->setClasses($classes);
     // Inline Editing
     // ///////////////
     $component = $this->getComponentByType('GridFieldDataColumns');
     $component->setDisplayFields(array('Selected' => array('title' => 'Selected', 'callback' => function ($record, $column_name, $grid) {
         return new CheckboxField_Readonly($column_name);
     }), 'HandlerName' => array('title' => 'Name', 'field' => 'ReadonlyField'), 'Label' => array('title' => 'Type', 'field' => 'ReadonlyField'), 'DescriptionPreview' => array('title' => 'Description', 'field' => 'ReadonlyField'), 'FormCount' => array('title' => 'Form Count', 'field' => 'ReadonlyField')));
 }
开发者ID:helpfulrobot,项目名称:briceburg-silverstripe-flexiform,代码行数:28,代码来源:GridFieldConfig_FlexiFormHandler.php


示例6: initialiseQuery

 /**
  * Set up the simplest initial query
  */
 public function initialiseQuery()
 {
     //@todo could probably use ClassInfo::hasTable() instead here
     // Get the tables to join to.
     // Don't get any subclass tables - let lazy loading do that.
     $tableClasses = ClassInfo::ancestry($this->dataClass, true);
     // Error checking
     if (!$tableClasses) {
         if (!SS_ClassLoader::instance()->hasManifest()) {
             user_error("DataObjects have been requested before the manifest is loaded. Please ensure you are not" . " querying the database in _config.php.", E_USER_ERROR);
         } else {
             user_error("DataList::create Can't find data classes (classes linked to tables) for" . " {$this->dataClass}. Please ensure you run dev/build after creating a new DataObject.", E_USER_ERROR);
         }
     }
     //Base table is not an ancestor in OrientDB
     $baseClass = array_pop($tableClasses);
     // Build our intial query
     $this->query = new OrientSQLQuery(array());
     $this->query->setDistinct(false);
     if ($sort = singleton($this->dataClass)->stat('default_sort')) {
         $this->sort($sort);
     }
     //TODO: sometimes we want to set from to be the @RID
     $this->query->setFrom("{$baseClass}");
     $obj = Injector::inst()->get($baseClass);
     $obj->extend('augmentDataQueryCreation', $this->query, $this);
 }
开发者ID:Cumquat,项目名称:silverstripe-orientdb-poc,代码行数:30,代码来源:OrientDataQuery.php


示例7: fire

 public function fire()
 {
     $this->info('Used cache location: ' . TEMP_FOLDER);
     SS_ClassLoader::instance()->getManifest()->regenerate();
     $this->info('regenerated manifest!');
     ClassInfo::reset_db_cache();
     $this->info('resetted db cache!');
 }
开发者ID:axyr,项目名称:silverstripe-console,代码行数:8,代码来源:ClearCommand.php


示例8: getPageTypes

 /**
  * Get a list of all page types available in the CMS
  *
  * @return array
  */
 protected function getPageTypes()
 {
     $types = array();
     foreach (SS_ClassLoader::instance()->getManifest()->getDescendantsOf("SiteTree") as $class) {
         $types[$class] = $class;
     }
     return $types;
 }
开发者ID:nathancox,项目名称:silverstripe-dashboard,代码行数:13,代码来源:DashboardSectionEditorPanel.php


示例9: register_double

 /**
  * The callback that Phockito will call every time there's a new double created
  *
  * @param string $double - The class name of the new double
  * @param string $of - The class new of the doubled class or interface
  * @param bool $isDoubleOfInterface - True if $of is an interface, False if it's a class
  */
 static function register_double($double, $of, $isDoubleOfInterface = false)
 {
     $manifest = SS_ClassLoader::instance()->getManifest();
     if (!$manifest instanceof PhockitoClassManifestUpdater) {
         $manifest = new PhockitoClassManifestUpdater($manifest);
         SS_ClassLoader::instance()->pushManifest($manifest, true);
     }
     $manifest->addDouble($double, $of, $isDoubleOfInterface);
 }
开发者ID:helpfulrobot,项目名称:hafriedlander-silverstripe-phockito,代码行数:16,代码来源:PhockitoClassManifestUpdater.php


示例10: tearDown

 public function tearDown()
 {
     SS_TemplateLoader::instance()->popManifest();
     SS_ClassLoader::instance()->popManifest();
     i18n::set_locale($this->originalLocale);
     Config::inst()->update('Director', 'alternate_base_folder', null);
     Config::inst()->update('SSViewer', 'theme', $this->_oldTheme);
     i18n::register_translator($this->origAdapter, 'core');
     parent::tearDown();
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:10,代码来源:i18nSSLegacyAdapterTest.php


示例11: tearDown

 public function tearDown()
 {
     SS_TemplateLoader::instance()->popManifest();
     SS_ClassLoader::instance()->popManifest();
     i18n::set_locale($this->originalLocale);
     Director::setBaseFolder(null);
     SSViewer::set_theme($this->_oldTheme);
     i18n::register_translator($this->origAdapter, 'core');
     parent::tearDown();
 }
开发者ID:normann,项目名称:sapphire,代码行数:10,代码来源:i18nSSLegacyAdapterTest.php


示例12: use_test_manifest

 /**
  * Pushes a class and template manifest instance that include tests onto the
  * top of the loader stacks.
  */
 public static function use_test_manifest()
 {
     $classManifest = new SS_ClassManifest(BASE_PATH, true, isset($_GET['flush']));
     SS_ClassLoader::instance()->pushManifest($classManifest, false);
     SapphireTest::set_test_class_manifest($classManifest);
     SS_TemplateLoader::instance()->pushManifest(new SS_TemplateManifest(BASE_PATH, project(), true, isset($_GET['flush'])));
     Config::inst()->pushConfigStaticManifest(new SS_ConfigStaticManifest(BASE_PATH, true, isset($_GET['flush'])));
     // Invalidate classname spec since the test manifest will now pull out new subclasses for each internal class
     // (e.g. Member will now have various subclasses of DataObjects that implement TestOnly)
     DataObject::clear_classname_spec_cache();
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:15,代码来源:TestRunner.php


示例13: findControllerFilePath

 /**
  * @param $controller
  *
  * @return bool|string
  */
 protected function findControllerFilePath($controller)
 {
     $controller = strtolower($controller);
     $classes = SS_ClassLoader::instance()->getManifest()->getClasses();
     $filePath = isset($classes[$controller]) ? $classes[$controller] : '';
     if (!is_file($filePath)) {
         $this->error("{$filePath} does not exist");
         return false;
     }
     return $filePath;
 }
开发者ID:axyr,项目名称:silverstripe-console,代码行数:16,代码来源:MakeFormCommand.php


示例14: initBundleDirectoryStructure

 /**
  * Inits bundle directory structure
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function initBundleDirectoryStructure(InputInterface $input, OutputInterface $output)
 {
     // Bootstrap SS so we can use module listing
     $frameworkPath = $this->container->getParameter('behat.silverstripe_extension.framework_path');
     $_GET['flush'] = 1;
     require_once $frameworkPath . '/core/Core.php';
     unset($_GET['flush']);
     $featuresPath = $input->getArgument('features');
     if (!$featuresPath) {
         throw new \InvalidArgumentException('Please specify a module name (e.g. "@mymodule")');
     }
     // Can't use 'behat.paths.base' since that's locked at this point to base folder (not module)
     $pathSuffix = $this->container->getParameter('behat.silverstripe_extension.context.path_suffix');
     $currentModuleName = null;
     $modules = \SS_ClassLoader::instance()->getManifest()->getModules();
     $currentModuleName = $this->container->getParameter('behat.silverstripe_extension.module');
     // get module from short notation if path starts from @
     if (preg_match('/^\\@([^\\/\\\\]+)(.*)$/', $featuresPath, $matches)) {
         $currentModuleName = $matches[1];
         // TODO Replace with proper module loader once AJShort's changes are merged into core
         if (!array_key_exists($currentModuleName, $modules)) {
             throw new \InvalidArgumentException(sprintf('Module "%s" not found', $currentModuleName));
         }
         $currentModulePath = $modules[$currentModuleName];
     }
     if (!$currentModuleName) {
         throw new \InvalidArgumentException('Can not find module to initialize suite.');
     }
     // TODO Retrieve from module definition once that's implemented
     if ($input->getOption('namespace')) {
         $namespace = $input->getOption('namespace');
     } else {
         $namespace = ucfirst($currentModuleName);
     }
     $namespace .= '\\' . $this->container->getParameter('behat.silverstripe_extension.context.namespace_suffix');
     $featuresPath = rtrim($currentModulePath . DIRECTORY_SEPARATOR . $pathSuffix, DIRECTORY_SEPARATOR);
     $basePath = $this->container->getParameter('behat.paths.base') . DIRECTORY_SEPARATOR;
     $bootstrapPath = $featuresPath . DIRECTORY_SEPARATOR . 'bootstrap';
     $contextPath = $bootstrapPath . DIRECTORY_SEPARATOR . 'Context';
     if (!is_dir($featuresPath)) {
         mkdir($featuresPath, 0777, true);
         mkdir($bootstrapPath, 0777, true);
         // touch($bootstrapPath.DIRECTORY_SEPARATOR.'_manifest_exclude');
         $output->writeln('<info>+d</info> ' . str_replace($basePath, '', realpath($featuresPath)) . ' <comment>- place your *.feature files here</comment>');
     }
     if (!is_dir($contextPath)) {
         mkdir($contextPath, 0777, true);
         $className = $this->container->getParameter('behat.context.class');
         file_put_contents($contextPath . DIRECTORY_SEPARATOR . $className . '.php', strtr($this->getFeatureContextSkelet(), array('%NAMESPACE%' => $namespace)));
         $output->writeln('<info>+f</info> ' . str_replace($basePath, '', realpath($contextPath)) . DIRECTORY_SEPARATOR . 'FeatureContext.php <comment>- place your feature related code here</comment>');
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-behat-extension,代码行数:58,代码来源:InitProcessor.php


示例15: build

 /**
  * Updates the database schema, creating tables & fields as necessary.
  */
 public function build()
 {
     // The default time limit of 30 seconds is normally not enough
     increase_time_limit_to(600);
     // Get all our classes
     SS_ClassLoader::instance()->getManifest()->regenerate();
     if (isset($_GET['returnURL'])) {
         echo "<p>Setting up the database; you will be returned to your site shortly....</p>";
         $this->doBuild(true);
         echo "<p>Done!</p>";
         $this->redirect($_GET['returnURL']);
     } else {
         $this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']), !isset($_REQUEST['dont_populate']));
     }
 }
开发者ID:nickbooties,项目名称:silverstripe-framework,代码行数:18,代码来源:DatabaseAdmin.php


示例16: getConfiguration

 /**
  * Gets the fields to configure the panel settings
  *
  * @return FieldList
  */
 public function getConfiguration()
 {
     $fields = parent::getConfiguration();
     $modeladmins = array();
     $models = $this->getManagedModelsFor($this->ModelAdminClass);
     foreach (SS_ClassLoader::instance()->getManifest()->getDescendantsOf("ModelAdmin") as $class) {
         $SNG = Injector::inst()->get($class);
         if ($SNG instanceof TestOnly) {
             continue;
         }
         $title = Config::inst()->get($class, "menu_title", Config::INHERITED);
         $modeladmins[$class] = $title ? $title : $class;
     }
     $fields->push(TextField::create("Count", _t('DashbordModelAdmin.COUNT', 'Number of records to display')));
     $fields->push(DropdownField::create("ModelAdminClass", _t('Dashboard.MODELADMINCLASS', 'Model admin tab'), $modeladmins)->addExtraClass('no-chzn')->setAttribute('data-lookupurl', $this->Link("modelsforpanel"))->setEmptyString("--- " . _t('Dashboard.PLEASESELECT', 'Please select') . " ---"));
     $fields->push(DropdownField::create("ModelAdminModel", _t('Dashboard.MODELADMINMODEL', 'Model'), $models)->addExtraClass('no-chzn'));
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:unclecheese-dashboard,代码行数:23,代码来源:DashboardModelAdminPanel.php


示例17: build

 /**
  * Updates the database schema, creating tables & fields as necessary.
  */
 public function build()
 {
     // The default time limit of 30 seconds is normally not enough
     increase_time_limit_to(600);
     // Get all our classes
     SS_ClassLoader::instance()->getManifest()->regenerate();
     $url = $this->getReturnURL();
     if ($url) {
         echo "<p>Setting up the database; you will be returned to your site shortly....</p>";
         $this->doBuild(true);
         echo "<p>Done!</p>";
         $this->redirect($url);
     } else {
         $quiet = $this->request->requestVar('quiet') !== null;
         $fromInstaller = $this->request->requestVar('from_installer') !== null;
         $populate = $this->request->requestVar('dont_populate') === null;
         $this->doBuild($quiet || $fromInstaller, $populate);
     }
 }
开发者ID:maent45,项目名称:redefine_renos,代码行数:22,代码来源:DatabaseAdmin.php


示例18: get_searchable_classes

 /**
  * @return array
  */
 public static function get_searchable_classes()
 {
     // First get any explicitly declared searchable classes
     $searchable = Config::inst()->get('ShopSearch', 'searchable');
     if (is_string($searchable) && strlen($searchable) > 0) {
         $searchable = array($searchable);
     } elseif (!is_array($searchable)) {
         $searchable = array();
     }
     // Add in buyables automatically if asked
     if (Config::inst()->get('ShopSearch', 'buyables_are_searchable')) {
         $buyables = SS_ClassLoader::instance()->getManifest()->getImplementorsOf('Buyable');
         if (is_array($buyables) && count($buyables) > 0) {
             foreach ($buyables as $c) {
                 $searchable[] = $c;
             }
         }
     }
     return array_unique($searchable);
 }
开发者ID:hex0id,项目名称:silverstripe-shop-search,代码行数:23,代码来源:ShopSearch.php


示例19: process

 /**
  * Processes data from container and console input.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @throws \RuntimeException
  */
 public function process(InputInterface $input, OutputInterface $output)
 {
     $featuresPath = $input->getArgument('features');
     // Can't use 'behat.paths.base' since that's locked at this point to base folder (not module)
     $pathSuffix = $this->container->getParameter('behat.silverstripe_extension.context.path_suffix');
     $currentModuleName = null;
     $modules = \SS_ClassLoader::instance()->getManifest()->getModules();
     // get module specified in behat.yml
     $currentModuleName = $this->container->getParameter('behat.silverstripe_extension.module');
     // get module from short notation if path starts from @
     if ($featuresPath && preg_match('/^\\@([^\\/\\\\]+)(.*)$/', $featuresPath, $matches)) {
         $currentModuleName = $matches[1];
         // TODO Replace with proper module loader once AJShort's changes are merged into core
         $currentModulePath = $modules[$currentModuleName];
         $featuresPath = str_replace('@' . $currentModuleName, $currentModulePath . DIRECTORY_SEPARATOR . $pathSuffix, $featuresPath);
         // get module from provided features path
     } elseif (!$currentModuleName && $featuresPath) {
         $path = realpath(preg_replace('/\\.feature\\:.*$/', '.feature', $featuresPath));
         foreach ($modules as $moduleName => $modulePath) {
             if (false !== strpos($path, realpath($modulePath))) {
                 $currentModuleName = $moduleName;
                 $currentModulePath = realpath($modulePath);
                 break;
             }
         }
         $featuresPath = $currentModulePath . DIRECTORY_SEPARATOR . $pathSuffix . DIRECTORY_SEPARATOR . $featuresPath;
         // if module is configured for profile and feature provided
     } elseif ($currentModuleName && $featuresPath) {
         $currentModulePath = $modules[$currentModuleName];
         $featuresPath = $currentModulePath . DIRECTORY_SEPARATOR . $pathSuffix . DIRECTORY_SEPARATOR . $featuresPath;
     }
     if ($input->getOption('namespace')) {
         $namespace = $input->getOption('namespace');
     } else {
         $namespace = ucfirst($currentModuleName);
     }
     if ($currentModuleName) {
         $this->container->get('behat.silverstripe_extension.context.class_guesser')->setNamespaceBase($namespace);
     }
     $this->container->get('behat.console.command')->setFeaturesPaths($featuresPath ? array($featuresPath) : array());
 }
开发者ID:helpfulrobot,项目名称:silverstripe-behat-extension,代码行数:49,代码来源:LocatorProcessor.php


示例20: classes_for_folder

 /**
  * Returns all classes contained in a certain folder.
  *
  * @todo Doesn't return additional classes that only begin
  *  with the filename, and have additional naming separated through underscores.
  *
  * @param string $folderPath Relative or absolute folder path
  * @return array Array of class names
  */
 public static function classes_for_folder($folderPath)
 {
     $absFolderPath = Director::getAbsFile($folderPath);
     $matchedClasses = array();
     $manifest = SS_ClassLoader::instance()->getManifest()->getClasses();
     foreach ($manifest as $class => $compareFilePath) {
         if (stripos($compareFilePath, $absFolderPath) === 0) {
             $matchedClasses[] = $class;
         }
     }
     return $matchedClasses;
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:21,代码来源:ClassInfo.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP SS_Datetime类代码示例发布时间:2022-05-23
下一篇:
PHP SS_Cache类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap