本文整理汇总了PHP中AppKernel::locateResource方法的典型用法代码示例。如果您正苦于以下问题:PHP AppKernel::locateResource方法的具体用法?PHP AppKernel::locateResource怎么用?PHP AppKernel::locateResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKernel
的用法示例。
在下文中一共展示了AppKernel::locateResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFixturesByAnnotation
public function getFixturesByAnnotation($test)
{
$annotationReader = new AnnotationReader();
$className = get_class($test->getTestClass());
$methodName = $test->getName();
$reflectionObject = new ReflectionObject(new $className());
$classAnnotations = $annotationReader->getClassAnnotations($reflectionObject);
$methodAnnotations = $annotationReader->getMethodAnnotations($reflectionObject->getMethod($methodName));
$testAnnotations = array_merge($classAnnotations, $methodAnnotations);
$fixtures = null;
foreach ($testAnnotations as $annotation) {
$arr = explode(":", $annotation->value, 2);
$path = $this->kernel->locateResource('@' . $arr[0]);
$fixtures[] = $path . 'DataFixtures/ORM/' . $arr[1];
}
codecept_debug("Fixtures to load:");
codecept_debug($fixtures);
return $fixtures;
}
示例2: onKernelException
/**
* Event handler that renders not found page
* in case of a NotFoundHttpException
*
* @param GetResponseForExceptionEvent $event
*
* @access public
* @return void
* @author Riad Hellal <hellal.riad@gmail.com>
*/
public function onKernelException(GetResponseForExceptionEvent $event)
{
$this->request = $event->getRequest($event);
// provide the better way to display a enhanced error page only in prod environment, if you want
if (in_array($this->kernel->getEnvironment(), array('test', 'prod'))) {
// exception object
$exception = $event->getException();
// new Response object
$response = new Response();
//$requestDuplicate = $this->request->duplicate(null, null, ['_controller' => 'MyAppSiteBundle:Default:exception']);
//$response = $this->kernel->handle($requestDuplicate, HttpKernelInterface::SUB_REQUEST);
if ($this->container->hasParameter('sfynx.auth.theme.layout.error.html') && $this->container->getParameter('sfynx.auth.theme.layout.error.html') != "") {
$path_error_file = realpath($this->kernel->locateResource($this->container->getParameter('sfynx.auth.theme.layout.error.html')));
$response->setContent(file_get_contents($path_error_file));
} else {
if ($this->container->hasParameter('sfynx.auth.theme.layout.error.route_name') && $this->container->getParameter('sfynx.auth.theme.layout.error.route_name') != "") {
$route_name = $this->container->getParameter('sfynx.auth.theme.layout.error.route_name');
} else {
$route_name = 'error_404';
}
$url = $this->container->get('sfynx.tool.route.factory')->getRoute($route_name, array('locale' => $this->locale));
$content = PiFileManager::getCurl('/' . $url, null, null, $this->request->getUriForPath(''));
$response->setContent($content);
}
// HttpExceptionInterface is a special type of exception
// that holds status code and header details
if (method_exists($exception, "getStatusCode")) {
$response->setStatusCode($exception->getStatusCode());
} else {
$response->setStatusCode('404');
}
if (method_exists($response, "getHeaders")) {
$response->headers->replace($exception->getHeaders());
}
// set the new $response object to the $event
$event->setResponse($response);
}
}