/** * {@inheritDoc} * Add the new bundle to the BundleBundle loader infrastructure instead of main kernel * * @param QuestionHelper $questionHelper dialog * @param InputInterface $input input * @param OutputInterface $output output * @param KernelInterface $kernel kernel * @param string $namespace namespace * @param string $bundle bundle * * @return string[] */ protected function updateKernel(QuestionHelper $questionHelper, InputInterface $input, OutputInterface $output, KernelInterface $kernel, $namespace, $bundle) { // skip if kernel manipulation disabled by options (defaults to true) $doUpdate = $input->getOption('doUpdateKernel'); if ($doUpdate == 'false') { return; } $auto = true; if ($input->isInteractive()) { $auto = $questionHelper->doAsk($output, $questionHelper->getQuestion('Confirm automatic update of your core bundle', 'yes', '?')); } $output->write('Enabling the bundle inside the core bundle: '); $coreBundle = $kernel->getBundle($input->getOption('loaderBundleName')); if (!is_a($coreBundle, '\\Graviton\\BundleBundle\\GravitonBundleInterface')) { throw new \LogicException('GravitonCoreBundle does not implement GravitonBundleInterface'); } $manip = new BundleBundleManipulator($coreBundle); try { $ret = $auto ? $manip->addBundle($namespace . '\\' . $bundle) : false; if (!$ret) { $reflected = new \ReflectionObject($kernel); return array(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename()), ' and add the following bundle in the <comment>GravitonCoreBundle::getBundles()</comment> method:', '', sprintf(' <comment>new %s(),</comment>', $namespace . '\\' . $bundle), ''); } } catch (\RuntimeException $e) { return array(sprintf('Bundle <comment>%s</comment> is already defined in <comment>%s)</comment>.', $namespace . '\\' . $bundle, 'sGravitonCoreBundle::getBundles()'), ''); } }
private function registersShutdownFunction(\ReflectionObject $object) { $fp = fopen($object->getFilename(), 'rb'); while (!feof($fp)) { if (false !== stripos(fread($fp, 4096), 'register_shutdown_function(')) { return true; } } fclose($fp); }
protected function updateKernel(OutputInterface $output, KernelInterface $kernel, Bundle $bundle) { $kernelManipulator = new KernelManipulator($kernel); $output->write(sprintf('> Enabling the bundle inside <info>%s</info>: ', $this->makePathRelative($kernelManipulator->getFilename()))); try { $ret = $kernelManipulator->addBundle($bundle->getBundleClassName()); if (!$ret) { $reflected = new \ReflectionObject($kernel); return array(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename()), ' and add the following bundle in the <comment>AppKernel::registerBundles()</comment> method:', '', sprintf(' <comment>new %s(),</comment>', $bundle->getBundleClassName()), ''); } } catch (\RuntimeException $e) { return array(sprintf('Bundle <comment>%s</comment> is already defined in <comment>AppKernel::registerBundles()</comment>.', $bundle->getBundleClassName()), ''); } }
function __construct() { //check we are using php 5 $this->check_php_version('5.0.0'); //use reflection to get the filename of the subclass that is inheriting from WP_PluginBase $reflector = new ReflectionObject($this); $this->plugin_file = $reflector->getFilename(); $this->plugin_dir = dirname($this->plugin_file) . '/'; $this->plugin_dir_name = plugin_basename($this->plugin_dir); $this->plugin_url = trailingslashit(plugins_url('', $this->plugin_file)); //load any plugin base deps $this->load_dependancies(); //get the plugin name from the filename. we assume the name of the plugin is the same as the file $this->init(); }
protected function updateKernel(InputInterface $input, OutputInterface $output, KernelInterface $kernel, $bundle) { $manip = new KernelManipulator($kernel); try { $ret = $manip->addBundle($bundle); if (!$ret) { $reflected = new \ReflectionObject($kernel); $output->writeln(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename())); $output->writeln(" and add the following bundle in the <comment>AppKernel::registerBundles()</comment> method:\n"); $output->writeln(sprintf(" <comment>new %s(),</comment>\n", $bundle)); } } catch (\RuntimeException $e) { $output->writeln(sprintf('Bundle <comment>%s</comment> is already defined in <comment>AppKernel::registerBundles()</comment>.', $bundle)); throw $e; } }
private function loadConfigurationFile() { $object = new \ReflectionObject($this); $classFilename = $object->getFilename(); $parentFolder = dirname($classFilename); do { if (file_exists($parentFolder . '/bootstrap.php')) { require_once $parentFolder . '/bootstrap.php'; break; } $scannedFolder = $parentFolder; $parentFolder = dirname($scannedFolder); } while ($scannedFolder !== $parentFolder); if (!function_exists('get_db_params')) { $this->fail('You have to create the file bootstrap.php in tests/ and define the function "get_db_params"'); } if (!function_exists('get_model_paths')) { $this->fail('You have to create the file bootstrap.php in tests/ and define the function "get_model_paths"'); } }
/** * Initialize the object * * @param BaseScriptClass $pObj A reference to the parent (calling) object * @param array $conf The configuration set for this module - from global array TBE_MODULES_EXT * @throws \RuntimeException * @see \TYPO3\CMS\Backend\Module\BaseScriptClass::checkExtObj() */ public function init(&$pObj, $conf) { $this->pObj = $pObj; // Path of this script: $reflector = new \ReflectionObject($this); $this->thisPath = dirname($reflector->getFilename()); if (!@is_dir($this->thisPath)) { throw new \RuntimeException('TYPO3 Fatal Error: Could not find path for class ' . get_class($this), 1381164687); } // Local lang: $this->incLocalLang(); // Setting MOD_MENU items as we need them for logging: $this->pObj->MOD_MENU = array_merge($this->pObj->MOD_MENU, $this->modMenu()); }
/** * @author go frendi * * @param string module_name * * @return string * @desc get module_path (folder name) of specified module_name (name space) */ public function cms_module_path($module_name = null) { // hack module path by changing the session, don't forget to unset !!! $module_path = ''; if ($module_name === null) { if ($this->__controller_module_path != null) { // no_cms_model and no_cms_autoupdate_model is called by instance controller // thus the position might not be represent the current module path // in this case we need data from controller $module_path = $this->__controller_module_path; } else { $reflector = new ReflectionObject($this); $file_name = $reflector->getFilename(); if (strpos($file_name, FCPATH . 'modules') === 0) { $file_name = trim(str_replace(FCPATH . 'modules', '', $file_name), DIRECTORY_SEPARATOR); $file_name_part = explode(DIRECTORY_SEPARATOR, $file_name); if (count($file_name_part) >= 2) { $module_path = $file_name_part[0]; } } } } else { if (!self::$__cms_model_properties['is_module_path_cached']) { $this->cms_adjust_module(); } if (array_key_exists($module_name, self::$__cms_model_properties['module_path'])) { $module_path = self::$__cms_model_properties['module_path'][$module_name]; } } return $module_path; }
protected function updateKernel(QuestionHelper $questionHelper, InputInterface $input, OutputInterface $output, KernelInterface $kernel, $namespace, $bundle) { $auto = true; if ($input->isInteractive()) { $auto = $questionHelper->askConfirmation($output, $questionHelper->getQuestion('Confirm automatic update of your Kernel', 'yes', '?'), true); } $output->write('Enabling the bundle inside the Kernel: '); $manip = new KernelManipulator($kernel); try { $ret = $auto ? $manip->addBundle($namespace . '\\' . $bundle) : false; if (!$ret) { $reflected = new \ReflectionObject($kernel); return array(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename()), ' and add the following bundle in the <comment>AppKernel::registerBundles()</comment> method:', '', sprintf(' <comment>new %s(),</comment>', $namespace . '\\' . $bundle), ''); } } catch (\RuntimeException $e) { return array(sprintf('Bundle <comment>%s</comment> is already defined in <comment>AppKernel::registerBundles()</comment>.', $namespace . '\\' . $bundle), ''); } }
/** * @author goFrendiAsgard * @param string module_name * @return string * @desc get module_path (folder name) of specified module_name (name space) */ protected function cms_module_path($module_name = NULL) { if ($module_name === NULL) { $module_path = ''; $reflector = new ReflectionObject($this); $file_name = $reflector->getFilename(); if (strpos($file_name, FCPATH . 'modules') === 0) { $file_name = trim(str_replace(FCPATH . 'modules', '', $file_name), DIRECTORY_SEPARATOR); $file_name_part = explode(DIRECTORY_SEPARATOR, $file_name); if (count($file_name_part) >= 2) { $module_path = $file_name_part[0]; } } return $module_path; } else { return $this->{$this->__cms_base_model_name}->cms_module_path($module_name); } }
private function updateKernel(OutputInterface $output, KernelInterface $kernel, $namespace, $bundle) { $output->write('Enabling the bundle inside the Kernel: '); $kernel = new KernelManipulator($kernel); if (!$kernel->addBundle($namespace . '\\' . $bundle)) { $reflected = new \ReflectionObject($kernel); return array(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename()), ' and add the following bundle in the <comment>AppKernel::registerBundles()</comment> method:', '', sprintf(' <comment>new %s(),</comment>', $namespace . '\\' . $bundle), ''); } }
/** * @param string $file * @return string string */ protected function getClassViewFilePath($file) { $object = new \ReflectionObject($this); $file = dirname($object->getFilename()) . DIRECTORY_SEPARATOR . \Uc::app()->theme->getViewsDir() . DIRECTORY_SEPARATOR . trim($file, DIRECTORY_SEPARATOR) . \Uc::app()->theme->getTemplateExtension(); return $file; }
public function testAddFilesMap() { $this->assertFalse(class_exists('Test_Magento_Autoload_Map', false)); $this->_loader->addFilesMap(array('Test_Magento_Autoload_Map' => 'dev/tests/unit/testsuite/Magento/Autoload/TestMap.php')); $reflection = new ReflectionObject(new Test_Magento_Autoload_Map()); $this->assertStringEndsWith('TestMap.php', $reflection->getFilename()); $this->assertFalse(class_exists('Unit_TestClassMapClass', false)); $this->_loader->addFilesMap(__DIR__ . '/Autoload/classmap.ser'); $reflection = new ReflectionObject(new Unit_TestClassMapClass()); $this->assertStringEndsWith('TestClassMapInFile.php', $reflection->getFilename()); }
private function updateKernel($dialog, InputInterface $input, OutputInterface $output, KernelInterface $kernel, $namespace, $bundle) { $auto = true; if ($input->isInteractive()) { $auto = $dialog->askConfirmation($output, $this->getQuestion('Confirm automatic update of your Kernel', 'yes', '?'), true); } $output->write('Enabling the bundle inside the Kernel: '); $manip = new KernelManipulator($kernel); $ret = $auto ? $manip->addBundle($namespace . '\\' . $bundle) : false; if (!$ret) { $reflected = new \ReflectionObject($kernel); return array(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename()), ' and add the following bundle in the <comment>AppKernel::registerBundles()</comment> method:', '', sprintf(' <comment>new %s(),</comment>', $namespace . '\\' . $bundle), ''); } }
protected function updateKernel($dialog, InputInterface $input, OutputInterface $output, KernelInterface $kernel, $namespace, $bundle) { $output->writeln('Enabling the bundle inside the Kernel'); $manip = new KernelManipulator($kernel); try { if (!$manip->addBundle($namespace)) { $reflected = new \ReflectionObject($kernel); return array(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename()), ' and add the following bundle in the <comment>AppKernel::registerBundles()</comment> method:', '', sprintf(' <comment>new %s(),</comment>', $namespace), ''); } } catch (\RuntimeException $e) { return array(sprintf('Bundle <comment>%s</comment> is already defined in <comment>AppKernel::registerBundles()</comment>.', $namespace), ''); } }
/** * Returns a list of paths to XML standard files for all sniffs in a standard. * * Any sniffs that do not have an XML standard file are obviously not included * in the returned array. If documentation is only being generated for some * sniffs (ie. $this->_sniffs is not empty) then all others sniffs will * be filtered from the results as well. * * @return string[] */ protected function getStandardFiles() { $phpcs = new PHP_CodeSniffer(); $phpcs->process(array(), $this->_standard); $sniffs = $phpcs->getSniffs(); $standardFiles = array(); foreach ($sniffs as $className => $sniffClass) { $object = new ReflectionObject($sniffClass); $sniff = $object->getFilename(); if (empty($this->_sniffs) === false) { // We are limiting the docs to certain sniffs only, so filter // out any unwanted sniffs. $parts = explode('_', $className); $sniffName = $parts[0] . '.' . $parts[2] . '.' . substr($parts[3], 0, -5); if (in_array($sniffName, $this->_sniffs) === false) { continue; } } $standardFile = str_replace(DIRECTORY_SEPARATOR . 'Sniffs' . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . 'Docs' . DIRECTORY_SEPARATOR, $sniff); $standardFile = str_replace('Sniff.php', 'Standard.xml', $standardFile); if (is_file($standardFile) === true) { $standardFiles[] = $standardFile; } } //end foreach return $standardFiles; }
/** * Get mtime of machine implementation. * * Useful to detect outdated cache entry in generated documentation. * * No need to override this method, it handles inherited classes * correctly. However if machine is loaded from database, a new * implementation is needed. * * This does not include filemtime(__FILE__) intentionaly. */ public function getMachineImplementationMTime() { $reflector = new \ReflectionObject($this); return filemtime($reflector->getFilename()); }