*/ public function getStatusCode() { $headers = $this->getHeaders(); if ($headers->has('http-code')) { // take into account possible 'follow location' $statusCodeHeaders = $headers->get('http-code', null, false); return empty($statusCodeHeaders) ? null : end($statusCodeHeaders); } throw new Exception('Unable to get status code: referred header information is missing.'); } /** * Checks if response status code is OK (status code = 20x) * @return bool whether response is OK. * @throws Exception */ public function getIsOk() {
* Checks if response status code is OK (status code = 20x) * @return bool whether response is OK. * @throws Exception */ public function getIsOk() { return strncmp('20', $this->getStatusCode(), 2) === 0; } /** * Returns default format automatically detected from headers and content. * @return string|null format name, 'null' - if detection failed. */
*/ public function __get($name) { $getter = 'get' . $name; if (method_exists($this, $getter)) { // read property, e.g. getName() return $this->$getter(); } // behavior property $this->ensureBehaviors(); foreach ($this->_behaviors as $behavior) { if ($behavior->canGetProperty($name)) {
$client = new Client(); $response = $client->createRequest() ->setMethod('GET') ->setUrl($this->url) ->setData($this->params) ->send(); if ($response->isOk) { $this->_dataSource = $response->data['result']; } } /** * @inheritdoc
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
{ $parentId = 1; $currentCategoryId = \Yii::$app->request->get('cat_id', $parentId); $dataProvider = new PiwigoDataProvider([ 'url' => 'http://47.88.62.231:9050/ws.php', 'params' => [ 'cat_id' => $currentCategoryId, 'format' => 'json', 'method' => 'pwg.categories.getImages', 'recursive' => true, ],
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require(__DIR__ . '/../../common/config/base.php'), require(__DIR__ . '/../../common/config/web.php'), require(__DIR__ . '/../config/base.php'), require(__DIR__ . '/../config/web.php') ); (new yii\web\Application($config))->run();