*/
public function checkBasePathPermission()
{
// if the check is been done already, skip further checks
if ($this->_isBasePathPermissionChecked) {
return;
}
if (!is_dir($this->basePath)) {
throw new InvalidConfigException("The directory does not exist: {$this->basePath}");
}
if (!is_writable($this->basePath)) {
throw new InvalidConfigException("The directory is not writable by the Web process: {$this->basePath}");
}
$this->_isBasePathPermissionChecked = true;
}
*
* @return string[] the path directory and the URL that the asset is published as.
* @throws InvalidArgumentException if the asset to be published does not exist.
*/
protected function publishDirectory($src, $options)
{
$this->checkBasePathPermission();
$dir = $this->hash($src);
$dstDir = $this->basePath . DIRECTORY_SEPARATOR . $dir;
if ($this->linkAssets) {
if (!is_dir($dstDir)) {
FileHelper::createDirectory(dirname($dstDir), $this->dirMode, true);
}
if (is_file($src)) {
return $this->_published[$path] = $this->publishFile($src);
}
return $this->_published[$path] = $this->publishDirectory($src, $options);
}
/**
* Publishes a file.
* @param string $src the asset file to be published
* @return string[] the path and the URL that the asset is published as.
* CSS or JS files using [[AssetManager::converter|asset converter]].
* @param AssetManager $am the asset manager to perform the asset publishing
*/
public function publish($am)
{
if ($this->sourcePath !== null && !isset($this->basePath, $this->baseUrl)) {
list($this->basePath, $this->baseUrl) = $am->publish($this->sourcePath, $this->publishOptions);
}
if (isset($this->basePath, $this->baseUrl) && ($converter = $am->getConverter()) !== null) {
foreach ($this->js as $i => $js) {
if (is_array($js)) {
$file = array_shift($js);
if (!isset($config['class'])) {
$config['class'] = $name;
}
/** @var AssetBundle $bundle */
$bundle = Yii::createObject($config);
if ($publish) {
$bundle->publish($this);
}
return $bundle;
}
/**
*/
public function getBundle($name, $publish = true)
{
if ($this->bundles === false) {
return $this->loadDummyBundle($name);
} elseif (!isset($this->bundles[$name])) {
return $this->bundles[$name] = $this->loadBundle($name, [], $publish);
} elseif ($this->bundles[$name] instanceof AssetBundle) {
return $this->bundles[$name];
} elseif (is_array($this->bundles[$name])) {
return $this->bundles[$name] = $this->loadBundle($name, $this->bundles[$name], $publish);
} elseif ($this->bundles[$name] === false) {
return $this->loadDummyBundle($name);
* @throws InvalidConfigException if the asset bundle does not exist or a circular dependency is detected
*/
public function registerAssetBundle($name, $position = null)
{
if (!isset($this->assetBundles[$name])) {
$am = $this->getAssetManager();
$bundle = $am->getBundle($name);
$this->assetBundles[$name] = false;
// register dependencies
$pos = isset($bundle->jsOptions['position']) ? $bundle->jsOptions['position'] : null;
foreach ($bundle->depends as $dep) {
$this->registerAssetBundle($dep, $pos);
}
* Registers this asset bundle with a view.
* @param View $view the view to be registered with
* @return static the registered asset bundle instance
*/
public static function register($view)
{
return $view->registerAssetBundle(get_called_class());
}
/**
* Initializes the bundle.
* If you override this method, make sure you call the parent implementation in the last.
*/
/**
* {@inheritdoc}
*/
public function clientValidateAttribute($model, $attribute, $view)
{
ValidationAsset::register($view);
$options = $this->getClientOptions($model, $attribute);
return 'yii.validation.required(value, messages, ' . Json::htmlEncode($options) . ');';
}
/**
$ajaxValidation = $this->isAjaxValidationEnabled();
if ($clientValidation) {
$validators = [];
foreach ($this->model->getActiveValidators($attribute) as $validator) {
/** @var \yii\validators\Validator $validator */
$js = $validator->clientValidateAttribute($this->model, $attribute, $this->form->getView());
if ($validator->enableClientValidation && $js != '') {
if ($validator->whenClient !== null) {
$js = "if (({$validator->whenClient})(attribute, value)) { $js }";
}
$validators[] = $js;
}
* Renders the opening tag of the field container.
* @return string the rendering result.
*/
public function begin()
{
if ($this->form->enableClientScript) {
$clientOptions = $this->getClientOptions();
if (!empty($clientOptions)) {
$this->form->attributes[] = $clientOptions;
}
}
$inputID = $this->getInputId();
}
$content = strtr($this->template, $this->parts);
} elseif (!is_string($content)) {
$content = call_user_func($content, $this);
}
return $this->begin() . "\n" . $content . "\n" . $this->end();
}
/**
* Renders the opening tag of the field container.
* @return string the rendering result.
*/
if ($this->inputTemplate) {
$input = isset($this->parts['{input}']) ?
$this->parts['{input}'] : Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
$this->parts['{input}'] = strtr($this->inputTemplate, ['{input}' => $input]);
}
}
return parent::render($content);
}
/**
* {@inheritdoc}
*/
public function checkbox($options = [], $enclosedByLabel = true)
*/
public function __toString()
{
// __toString cannot throw exception
// use trigger_error to bypass this limitation
try {
return $this->render();
} catch (\Throwable $e) {
if (PHP_VERSION_ID < 70400) {
trigger_error(ErrorHandler::convertExceptionToString($e), E_USER_ERROR);
return '';
}
<?php $form = ActiveForm::begin([
'fieldConfig' => [
'template' => '{input}'
]
]); ?>
<?= $form->field($model, 'username')->input('email', ['class' => 'form-control', 'autofocus' => true, 'placeholder' => 'Email']); ?>
<?= $form->field($model, 'password')->passwordInput(['class' => 'form-control', 'placeholder' => 'Password']) ?>
<div class="form-group field-loginform-showPass">
<div class="checkbox">
<label for="loginform-showPass">
{
$_obInitialLevel_ = ob_get_level();
ob_start();
ob_implicit_flush(false);
extract($_params_, EXTR_OVERWRITE);
try {
require $_file_;
return ob_get_clean();
} catch (\Exception $e) {
while (ob_get_level() > $_obInitialLevel_) {
if (!@ob_end_clean()) {
ob_clean();
}
$this->renderers[$ext] = Yii::createObject($this->renderers[$ext]);
}
/** @var ViewRenderer $renderer */
$renderer = $this->renderers[$ext];
$output = $renderer->render($this, $viewFile, $params);
} else {
$output = $this->renderPhpFile($viewFile, $params);
}
$this->afterRender($viewFile, $params, $output);
}
array_pop($this->_viewFiles);
$this->context = $oldContext;
* @throws InvalidCallException if the view cannot be resolved.
* @see renderFile()
*/
public function render($view, $params = [], $context = null)
{
$viewFile = $this->findViewFile($view, $context);
return $this->renderFile($viewFile, $params, $context);
}
/**
* Finds the view file based on the given view name.
* @param string $view the view name or the [path alias](guide:concept-aliases) of the view file. Please refer to [[render()]]
* on how to specify this parameter.
* These parameters will not be available in the layout.
* @return string the rendering result.
* @throws InvalidArgumentException if the view file or the layout file does not exist.
*/
public function render($view, $params = [])
{
$content = $this->getView()->render($view, $params, $this);
return $this->renderContent($content);
}
/**
* Renders a static string by applying a layout.
* @param string $content the static string being rendered
} elseif (Yii::$app->user->identity->role === User::ROLE_ADMIN) {
return $this->redirect(Rgurl::to(['admin/admin/index']));
} elseif (Yii::$app->user->identity->role === User::ROLE_EDITOR) {
return $this->redirect(Rgurl::to(['admin/admin/index']));
}
}
return $this->render('login', [
'model' => $model,
]);
}
/**
* Updates an existing User model.
$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__ . '/../vendor/yiisoft/yii2/Yii.php'; require __DIR__ . '/../config/bootstrap.php'; $config = require __DIR__ . '/../config/api.php'; (new yii\web\Application($config))->run();
$_COOKIE = [
'PHPSESSID' => 'a1eec9ed68aa4019f3fc805b4f18857e',
];
$_SESSION = [
'__flash' => [],
'country_code' => 'US',
'user_region_id' => unserialize('O:21:"MongoDB\\BSON\\ObjectId":1:{s:3:"oid";s:24:"5bd6c180b5551ee2538b47da";}'),
];