本文整理汇总了PHP中ReflectionObject::getFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionObject::getFileName方法的具体用法?PHP ReflectionObject::getFileName怎么用?PHP ReflectionObject::getFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionObject
的用法示例。
在下文中一共展示了ReflectionObject::getFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getViewTemplate
/**
* @return string
*/
public function getViewTemplate()
{
// set default view name
if (is_null($this->viewTemplate)) {
$reflected = new \ReflectionObject($this);
$viewTemplate = substr($reflected->getFileName(), 0, -4);
$templateFound = false;
foreach (self::$viewExtensions as $extension) {
if (file_exists($viewTemplate . '.' . ltrim($extension, '.'))) {
$templateFound = true;
break;
}
}
if (!$templateFound) {
// try to get parent template if any
$parentReflectedClass = $reflected->getParentClass();
if ($parentReflectedClass->isInstantiable() && $parentReflectedClass->implementsInterface(RenderableActionInterface::class)) {
$parentViewTemplate = $parentReflectedClass->newInstance()->getViewTemplate();
$viewTemplate = $parentViewTemplate;
}
}
$this->viewTemplate = $viewTemplate;
}
return $this->viewTemplate;
}
示例2: load
/**
* @param AdminInterface $admin
*
* @return mixed
* @throws \RuntimeException
*/
public function load(AdminInterface $admin)
{
$filename = $this->cacheFolder . '/route_' . md5($admin->getCode());
$cache = new ConfigCache($filename, $this->debug);
if (!$cache->isFresh()) {
$resources = array();
$routes = array();
$reflection = new \ReflectionObject($admin);
$resources[] = new FileResource($reflection->getFileName());
if (!$admin->getRoutes()) {
throw new \RuntimeException('Invalid data type, Admin::getRoutes must return a RouteCollection');
}
foreach ($admin->getRoutes()->getElements() as $code => $route) {
$routes[$code] = $route->getDefault('_sonata_name');
}
if (!is_array($admin->getExtensions())) {
throw new \RuntimeException('extensions must be an array');
}
foreach ($admin->getExtensions() as $extension) {
$reflection = new \ReflectionObject($extension);
$resources[] = new FileResource($reflection->getFileName());
}
$cache->write(serialize($routes), $resources);
}
return unserialize(file_get_contents($filename));
}
示例3: getPath
/**
* Gets the Module directory path.
*
* @return string The Module absolute path
*
* @api
*/
public function getPath()
{
if (null === $this->reflected) {
$this->reflected = new \ReflectionObject($this);
}
return dirname($this->reflected->getFileName());
}
示例4: getConfiguration
public function getConfiguration(array $config, ContainerBuilder $container)
{
$configuration = new Configuration($this->getAlias());
$r = new \ReflectionObject($configuration);
$container->addResource(new FileResource($r->getFileName()));
return $configuration;
}
示例5: testCacheIsFreshAfterCacheClearedWithWarmup
public function testCacheIsFreshAfterCacheClearedWithWarmup()
{
$input = new ArrayInput(array('cache:clear'));
$application = new Application($this->kernel);
$application->setCatchExceptions(false);
$application->doRun($input, new NullOutput());
// Ensure that all *.meta files are fresh
$finder = new Finder();
$metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta');
// simply check that cache is warmed up
$this->assertGreaterThanOrEqual(1, count($metaFiles));
foreach ($metaFiles as $file) {
$configCache = new ConfigCache(substr($file, 0, -5), true);
$this->assertTrue($configCache->isFresh(), sprintf('Meta file "%s" is not fresh', (string) $file));
}
// check that app kernel file present in meta file of container's cache
$containerRef = new \ReflectionObject($this->kernel->getContainer());
$containerFile = $containerRef->getFileName();
$containerMetaFile = $containerFile . '.meta';
$kernelRef = new \ReflectionObject($this->kernel);
$kernelFile = $kernelRef->getFileName();
/** @var ResourceInterface[] $meta */
$meta = unserialize(file_get_contents($containerMetaFile));
$found = false;
foreach ($meta as $resource) {
if ((string) $resource === $kernelFile) {
$found = true;
break;
}
}
$this->assertTrue($found, 'Kernel file should present as resource');
}
示例6: coreTest
protected function coreTest(array $arguments)
{
$input = new ArrayInput($arguments);
$application = new Application(static::$kernel);
$application->setCatchExceptions(false);
$application->doRun($input, new NullOutput());
// Ensure that all *.meta files are fresh
$finder = new Finder();
$metaFiles = $finder->files()->in(static::$kernel->getCacheDir())->name('*.php.meta');
// simply check that cache is warmed up
$this->assertGreaterThanOrEqual(1, count($metaFiles));
foreach ($metaFiles as $file) {
$configCache = new ConfigCache(substr($file, 0, -5), true);
$this->assertTrue($configCache->isFresh(), sprintf('Meta file "%s" is not fresh', (string) $file));
}
// check that app kernel file present in meta file of container's cache
$containerRef = new \ReflectionObject(static::$kernel->getContainer());
$containerFile = $containerRef->getFileName();
$containerMetaFile = $containerFile . '.meta';
$kernelRef = new \ReflectionObject(static::$kernel);
$kernelFile = $kernelRef->getFileName();
/** @var ResourceInterface[] $meta */
$meta = unserialize(file_get_contents($containerMetaFile));
$found = false;
foreach ($meta as $resource) {
if ((string) $resource === $kernelFile) {
$found = true;
break;
}
}
$this->assertTrue($found, 'Kernel file should present as resource');
$this->assertRegExp(sprintf('/\'kernel.name\'\\s*=>\\s*\'%s\'/', static::$kernel->getName()), file_get_contents($containerFile), 'kernel.name is properly set on the dumped container');
$this->assertEquals(ini_get('memory_limit'), '1024M');
}
示例7: testAnnotationGenerator
public function testAnnotationGenerator()
{
$client = static::createClient();
$this->assertTrue(AnnotationTagGenerator::$haveBeenRun);
$object = new \ReflectionObject($client->getContainer());
$this->assertTrue(strpos(file_get_contents($object->getFileName()), '/* This is a test for annotation generation */') !== false);
}
示例8: setUp
public function setUp()
{
$this->autoloader = new Loader();
$loaderReflection = new \ReflectionObject($this->autoloader);
$this->loaderFilePath = $loaderReflection->getFileName();
spl_autoload_register($this->autoloader);
}
示例9: load
public function load($resource, $type = null)
{
$collection = new RouteCollection();
foreach ($this->adminFactory->getAdmins() as $adminId => $admin) {
$routePatternPrefix = $admin->getRoutePatternPrefix();
$routeNamePrefix = $admin->getRouteNamePrefix();
foreach ($admin->getActions() as $action) {
$defaults = array(
'_controller' => 'WhiteOctoberAdminBundle:Admin:execute',
'_white_october_admin.admin' => $adminId,
'_white_october_admin.action' => $action->getFullName(),
);
$defaults = array_merge($action->getRouteDefaults(), $defaults);
$route = new Route($routePatternPrefix.$action->getRoutePatternSuffix(), $defaults, $action->getRouteRequirements());
$collection->add($ups = $routeNamePrefix.'_'.$action->getRouteNameSuffix(), $route);
$reflection = new \ReflectionObject($action);
$collection->addResource(new FileResource($reflection->getFileName()));
}
$reflection = new \ReflectionObject($admin);
$collection->addResource(new FileResource($reflection->getFileName()));
}
return $collection;
}
示例10: testGetCollectorPath
public function testGetCollectorPath()
{
$finder = new Finder();
$collector = new \Itkg\Profiler\DataCollector\CacheDataCollector();
$reflector = new \ReflectionObject($collector);
$directory = dirname($reflector->getFileName());
$this->assertEquals($directory . '/../Resources/views/collector/cache.html.php', $finder->getCollectorPath($collector));
}
示例11: getRootDir
/**
* @return string
*/
protected function getRootDir()
{
if (!isset($this['root_dir'])) {
$reflObject = new \ReflectionObject($this);
$this['root_dir'] = dirname($reflObject->getFileName());
}
return realpath($this['root_dir']) ?: $this['root_dir'];
}
示例12: getPath
/**
* {@inheritdoc}
*/
public final function getPath()
{
if (null === $this->path) {
$reflObject = new \ReflectionObject($this);
$this->path = dirname($reflObject->getFileName());
}
return $this->path;
}
示例13: addObjectResource
/**
* Adds the object class hierarchy as resources.
*
* @param object $object An object instance
*/
public function addObjectResource($object)
{
$parent = new \ReflectionObject($object);
$this->addResource(new FileResource($parent->getFileName()));
while ($parent = $parent->getParentClass()) {
$this->addResource(new FileResource($parent->getFileName()));
}
}
示例14: getRootDir
/**
* @return string
*/
public function getRootDir()
{
if (null === $this->rootDir) {
$r = new \ReflectionObject($this);
$this->rootDir = str_replace('\\', '/', dirname($r->getFileName()));
}
return $this->rootDir;
}
示例15: __construct
public function __construct()
{
$r = new \ReflectionObject($this);
$this->path = dirname($r->getFileName());
$this->configDir = dirname($this->path) . '/config';
$this->loadConfiguration();
$this->loadRoutes();
$this->configureTemplating();
}