本文整理汇总了PHP中ezcBase::inDevMode方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcBase::inDevMode方法的具体用法?PHP ezcBase::inDevMode怎么用?PHP ezcBase::inDevMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcBase
的用法示例。
在下文中一共展示了ezcBase::inDevMode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a new controller object and sets all the request variables as class variables.
*
* @throws ezcMvcControllerException if the action method is empty
* @param string $action
* @param ezcMvcRequest $request
*/
public function __construct($action, ezcMvcRequest $request)
{
if (ezcBase::inDevMode() && (!is_string($action) || strlen($action) == 0)) {
throw new ezcMvcControllerException("The '" . get_class($this) . "' controller requires an action.");
}
$this->action = $action;
$this->setRequestVariables($request);
}
示例2: getRoutingInformation
/**
* Returns routing information, including a controller classname from the set of routes.
*
* This method is run by the dispatcher to obtain a controller. It uses the
* user implemented createRoutes() method from the inherited class to fetch the
* routes. It then loops over these routes in order - the first one that
* matches the request returns the routing information. The loop stops as
* soon as a route has matched. In case none of the routes matched
* with the request data an exception is thrown.
*
* @throws ezcMvcNoRoutesException when there are no routes defined.
* @throws ezcBaseValueException when one of the returned routes was not
* actually an object implementing the ezcMvcRoute interface.
* @throws ezcMvcRouteNotFoundException when no routes matched the request URI.
* @return ezcMvcRoutingInformation
*/
public function getRoutingInformation()
{
$routes = $this->createRoutes();
if (ezcBase::inDevMode() && (!is_array($routes) || !count($routes))) {
throw new ezcMvcNoRoutesException();
}
foreach ($routes as $route) {
if (ezcBase::inDevMode() && !$route instanceof ezcMvcRoute) {
throw new ezcBaseValueException('route', $route, 'instance of ezcMvcRoute');
}
$routingInformation = $route->matches($this->request);
if ($routingInformation !== null) {
return $routingInformation;
}
}
throw new ezcMvcRouteNotFoundException($this->request);
}
示例3: getRoutingInformation
/**
* Returns routing information, including a controller classname from the set of routes.
*
* This method is run by the dispatcher to obtain a controller. It uses the
* user implemented createRoutes() method from the inherited class to fetch the
* routes. It then loops over these routes in order - the first one that
* matches the request returns the routing information. The loop stops as
* soon as a route has matched. In case none of the routes matched
* with the request data an exception is thrown.
*
* @throws ezcMvcNoRoutesException when there are no routes defined.
* @throws ezcBaseValueException when one of the returned routes was not
* actually an object implementing the ezcMvcRoute interface.
* @throws ezcMvcRouteNotFoundException when no routes matched the request URI.
* @return ezcMvcRoutingInformation
*/
public function getRoutingInformation()
{
$routes = $this->createRoutes();
if (ezcBase::inDevMode() && (!is_array($routes) || !count($routes))) {
throw new ezcMvcNoRoutesException();
}
foreach ($routes as $route) {
if (ezcBase::inDevMode() && !$route instanceof ezcMvcRoute) {
throw new ezcBaseValueException('route', $route, 'instance of ezcMvcRoute');
}
$routingInformation = $route->matches($this->request);
if ($routingInformation !== null) {
// Add the router to the routing information struct, so that
// can be passed to the controllers for reversed route
// generation.
$routingInformation->router = $this;
return $routingInformation;
}
}
throw new ezcMvcRouteNotFoundException($this->request);
}
示例4: testSetGetRunMode
public function testSetGetRunMode()
{
self::assertEquals(ezcBase::MODE_DEVELOPMENT, ezcBase::getRunMode());
self::assertEquals(true, ezcBase::inDevMode());
ezcBase::setRunMode(ezcBase::MODE_PRODUCTION);
self::assertEquals(ezcBase::MODE_PRODUCTION, ezcBase::getRunMode());
self::assertEquals(false, ezcBase::inDevMode());
ezcBase::setRunMode(ezcBase::MODE_DEVELOPMENT);
self::assertEquals(ezcBase::MODE_DEVELOPMENT, ezcBase::getRunMode());
self::assertEquals(true, ezcBase::inDevMode());
}
示例5: runResponseFilters
function runResponseFilters(ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result, ezcMvcResponse $response)
{
if (!ezcBase::inDevMode()) {
if (in_array('gzip', $request->accept->encodings)) {
$filter = new ezcMvcGzipResponseFilter();
$filter->filterResponse($response);
} else {
if (in_array('deflate', $request->accept->encodings)) {
$filter = new ezcMvcGzDeflateResponseFilter();
$filter->filterResponse($response);
}
}
}
}
示例6: getResponseWriter
/**
* Uses the configuration to fetch the response writer
*
* @throws ezcMvcInvalidConfiguration when the returned object is of the wrong class
*
* @param ezcMvcRoutingInformation $routingInformation
* @param ezcMvcRequest $request
* @param ezcMvcResult $result
* @param ezcMvcResponse $response
* @return ezcMvcResponseWriter
*/
protected function getResponseWriter(ezcMvcRoutingInformation $routingInformation, ezcMvcRequest $request, ezcMvcResult $result, ezcMvcResponse $response)
{
$responseWriter = $this->configuration->createResponseWriter($routingInformation, $request, $result, $response);
if (ezcBase::inDevMode() && !$responseWriter instanceof ezcMvcResponseWriter) {
throw new ezcMvcInvalidConfiguration('responseWriter', $responseWriter, 'instance of ezcMvcResponseWriter');
}
return $responseWriter;
}
示例7: createResponseBody
/**
* Creates a controller from the set of routes.
*
* This method is run by the createResponse() method to obtain a rendered
* result from data from the controller. It uses the user implemented
* createZones() method from the inherited class to fetch the different
* zones of the view, and then loops over these zones in order. Each zone's
* results are made available to subsequent zones. Each zone will be
* processed by a view handler of the ezcMvcViewHandler class.
*
* @throws ezcMvcNoZonesException when there are no zones defined.
* @throws ezcBaseValueException when one of the returned zones was not
* actually an object implementing the ezcMvcViewHandler interface.
* @return mixed
*/
protected function createResponseBody()
{
$processed = array();
$zones = $this->createZones(true);
if (ezcBase::inDevMode() && (!is_array($zones) || !count($zones))) {
throw new ezcMvcNoZonesException();
}
// get the last zone
$lastZone = array_pop($zones);
array_push($zones, $lastZone);
foreach ($zones as $zone) {
if (ezcBase::inDevMode() && !$zone instanceof ezcMvcViewHandler) {
throw new ezcBaseValueException('zone', $zone, 'instance of ezcMvcViewHandler');
}
// Get the variables returned by the controller for the view
foreach ($this->result->variables as $propertyName => $propertyValue) {
// Send it verbatim to the template processor
$zone->send($propertyName, $propertyValue);
}
// Zones are additional templates that the final view should be built
// with. The main page layout is the last zone returned from
// createZones() method.
foreach ($processed as $processedZone) {
$zone->send($processedZone->getName(), $processedZone->getResult());
}
$zone->process($zone === $lastZone);
$processed[] = $zone;
}
return $zone->getResult();
}