_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q25600 | Asset.enqueueStyle | train | protected function enqueueStyle()
{
wp_enqueue_style(
$this->getHandle(),
$this->getUrl(),
$this->getDependencies(),
$this->getVersion(),
$this->getArgument()
);
if (! empty($this->inline)) {
foreach ($this->inline as $... | php | {
"resource": ""
} |
q25601 | Asset.localize | train | public function localize(string $name, array $data): AssetInterface
{
$this->localize[$name] = $data;
return $this;
} | php | {
"resource": ""
} |
q25602 | Asset.inline | train | public function inline(string $code, bool $after = true): AssetInterface
{
$this->inline[] = [
'code' => $code,
'position' => $after ? 'after' : 'before'
];
return $this;
} | php | {
"resource": ""
} |
q25603 | Asset.attributes | train | public function attributes(array $attributes): AssetInterface
{
if (is_null($this->getType())) {
throw new AssetException('The asset must have a type.');
}
$hook = 'script' === $this->getType() ? 'script_loader_tag' : 'style_loader_tag';
$key = strtolower(trim($this->get... | php | {
"resource": ""
} |
q25604 | TaxonomyFieldRepository.add | train | public function add($field)
{
if (is_array($field)) {
foreach ($field as $item) {
$this->add($item);
}
} else {
$this->fields[] = $field;
}
} | php | {
"resource": ""
} |
q25605 | TaxonomyFieldRepository.getFieldByName | train | public function getFieldByName(string $name)
{
$found = array_filter($this->fields, function ($field) use ($name) {
/** @var FieldTypeInterface $field */
return $name === $field->getBaseName();
});
if (! empty($found)) {
return array_pop($found);
... | php | {
"resource": ""
} |
q25606 | WordPress.getFilters | train | public function getFilters()
{
return [
/**
* Formatting filters.
*/
new \Twig_Filter('wpantispam', function ($email, $encoding = 0) {
return antispambot($email, $encoding);
}),
new \Twig_Filter('wpautop', function ($t... | php | {
"resource": ""
} |
q25607 | WordPressBodyClass.dispatchBodyClass | train | protected function dispatchBodyClass(Route $route)
{
return function ($classes) use ($route) {
if ($route->hasCondition()) {
return $classes;
}
$tokens = array_filter(array_map(function ($token) use ($route) {
switch ($type = $token[0]) {
... | php | {
"resource": ""
} |
q25608 | VendorPublishCommand.parseChoice | train | protected function parseChoice($choice)
{
list($type, $value) = explode(': ', strip_tags($choice));
if ($type === 'Provider') {
$this->provider = $value;
} elseif ($type === 'Tag') {
$this->tags = [$value];
}
} | php | {
"resource": ""
} |
q25609 | Support.parse | train | protected function parse(array $features)
{
$allowed = [];
foreach ($features as $feature => $value) {
if (is_int($feature)) {
// Allow theme features without options.
// Though post formats must be added with properties.
// Here we first ... | php | {
"resource": ""
} |
q25610 | Support.register | train | public function register()
{
if (! function_exists('add_theme_support') || empty($this->features)) {
return;
}
foreach ($this->features as $feature => $value) {
add_theme_support($feature, $value);
}
} | php | {
"resource": ""
} |
q25611 | FieldTransformer.transform | train | public function transform(FieldTypeInterface $field)
{
return [
'attributes' => $field->getAttributes(),
'basename' => $field->getBaseName(),
'component' => $field->getComponent(),
'data_type' => $field->getOption('data_type', ''),
'default' => $fi... | php | {
"resource": ""
} |
q25612 | CollectionFieldTransformer.getOptions | train | protected function getOptions(FieldTypeInterface $field)
{
$options = parent::getOptions($field);
$options['items'] = array_map(function ($id) {
return [
'attributes' => wp_prepare_attachment_for_js($id),
'id' => $id
];
}, (array) $fie... | php | {
"resource": ""
} |
q25613 | Form.setPrefix | train | public function setPrefix(string $prefix): FieldTypeInterface
{
$this->prefix = $prefix;
// Update all attached fields with the given prefix.
foreach ($this->repository->all() as $field) {
/** @var FieldTypeInterface $field */
$field->setPrefix($prefix);
}
... | php | {
"resource": ""
} |
q25614 | Form.setTheme | train | public function setTheme(string $theme): FieldTypeInterface
{
$this->options['theme'] = $theme;
// Update all attached fields with the given theme.
foreach ($this->repository->all() as $field) {
/** @var FieldTypeInterface $field */
$field->setTheme($theme);
... | php | {
"resource": ""
} |
q25615 | Form.handleRequest | train | public function handleRequest(Request $request): FormInterface
{
$fields = $this->repository->all();
$this->validator = $this->validation->make(
$request->all(),
$this->getFormRules($fields),
$this->getFormMessages($fields),
$this->getFormPlaceholders... | php | {
"resource": ""
} |
q25616 | Form.getFormRules | train | protected function getFormRules(array $fields)
{
$rules = [];
foreach ($fields as $field) {
/** @var FieldTypeInterface $field */
$rules[$field->getName()] = $field->getOption('rules');
}
return $rules;
} | php | {
"resource": ""
} |
q25617 | Form.getFormMessages | train | protected function getFormMessages(array $fields)
{
// Each message is defined by field and its own rules.
// In our case, we need to prepend the field name (attribute)
// using a "dot" notation. Ex.: email.required
$messages = [];
foreach ($fields as $field) {
/... | php | {
"resource": ""
} |
q25618 | Form.error | train | public function error(string $name = '', bool $first = false)
{
$errors = $this->errors();
if (empty($name)) {
// Return all errors messages by default if the
// name argument is not specified.
return $errors->all();
}
$field = $this->repository-... | php | {
"resource": ""
} |
q25619 | Form.render | train | public function render(): string
{
$view = $this->viewer->make($this->getView(), $this->getFormData());
// Indicates that the form has been rendered at least once.
// Then return its content.
$this->rendered = true;
return $view->render();
} | php | {
"resource": ""
} |
q25620 | Form.setGroupView | train | public function setGroupView(string $view, string $group = 'default'): FormInterface
{
// Verify that the form has the mentioned group.
// If not, throw an error.
if (! $this->repository()->hasGroup($group)) {
throw new DomainException('You cannot change the view of an undefined ... | php | {
"resource": ""
} |
q25621 | Form.getView | train | public function getView(bool $prefixed = true): string
{
if ($prefixed) {
return $this->buildViewPath($this->getTheme(), $this->view);
}
return $this->view;
} | php | {
"resource": ""
} |
q25622 | Form.validateOptions | train | protected function validateOptions(array $options)
{
$validated = [];
foreach ($options as $name => $option) {
if (! in_array($name, $this->getAllowedOptions())) {
throw new DomainException('The "'.$name.'" option is not allowed on the provided form.');
}
... | php | {
"resource": ""
} |
q25623 | Form.parseOptions | train | protected function parseOptions(array $options)
{
// Make sure to keep defined default attributes on the form.
$options['attributes'] = array_merge($this->getAttributes(), $options['attributes']);
// Define nonce default values if "method" attribute is set to "post".
if (isset($opti... | php | {
"resource": ""
} |
q25624 | Form.addAttribute | train | public function addAttribute(string $name, string $value, $overwrite = false): FieldTypeInterface
{
if (isset($this->options['attributes'][$name]) && ! $overwrite) {
$this->options['attributes'][$name] .= ' '.$value;
} else {
$this->options['attributes'][$name] = $value;
... | php | {
"resource": ""
} |
q25625 | FormBuilder.validateOptions | train | protected function validateOptions(array $options, FieldTypeInterface $field)
{
$parsed = [];
foreach ($options as $key => $value) {
if (! in_array($key, $field->getAllowedOptions(), true)) {
throw new \DomainException('The "'.$key.'" option is not allowed on the provide... | php | {
"resource": ""
} |
q25626 | FormBuilder.add | train | public function add(FieldTypeInterface $field): FormBuilderInterface
{
/** @var BaseType $field */
$opts = $this->validateOptions(array_merge([
'errors' => $this->form->getOption('errors'),
'theme' => $this->form->getOption('theme')
], $field->getOptions()), $field);
... | php | {
"resource": ""
} |
q25627 | SetRequestForConsole.bootstrap | train | public function bootstrap(Application $app)
{
$uri = $app->make('config')->get('app.url', 'http://localhost');
$components = parse_url($uri);
$server = $_SERVER;
if (isset($components['path'])) {
$server = array_merge($server, [
'SCRIPT_FILENAME' => $co... | php | {
"resource": ""
} |
q25628 | UserServiceProvider.registerUserField | train | protected function registerUserField()
{
$this->app->bind('themosis.user.field', function ($app) {
$viewFactory = $app['view'];
$viewFactory->addLocation(__DIR__.'/views');
return new UserField(
new FieldsRepository(),
$app['action'],
... | php | {
"resource": ""
} |
q25629 | ModelMakeCommand.createController | train | protected function createController()
{
$controller = Str::studly(class_basename($this->argument('name')));
$modelName = $this->qualifyClass($this->getNameInput());
$this->call('make:controller', [
'name' => "{$controller}Controller",
'--model' => $this->option('reso... | php | {
"resource": ""
} |
q25630 | ImageSize.parse | train | protected function parse(array $sizes)
{
$images = [];
foreach ($sizes as $slug => $properties) {
list($width, $height, $crop, $label) = $this->parseProperties($properties, $slug);
$images[$slug] = [
'width' => $width,
'height' => $height,
... | php | {
"resource": ""
} |
q25631 | ImageSize.parseProperties | train | protected function parseProperties(array $properties, string $slug)
{
switch (count($properties)) {
case 1:
// Square with defaults.
return [$properties[0], $properties[0], false, false];
break;
case 2:
// Custom size wi... | php | {
"resource": ""
} |
q25632 | ImageSize.addToDropDown | train | public function addToDropDown(array $options)
{
foreach ($this->sizes as $slug => $props) {
if ($props['label'] && ! isset($options[$slug])) {
$options[$slug] = $props['label'];
}
}
return $options;
} | php | {
"resource": ""
} |
q25633 | RouteCacheCommand.getFreshApplicationRoutes | train | protected function getFreshApplicationRoutes()
{
return tap($this->getFreshApplication()['router']->getRoutes(), function ($routes) {
/** @var RouteCollection $routes */
$routes->refreshNameLookups();
$routes->refreshActionLookups();
});
} | php | {
"resource": ""
} |
q25634 | RouteCacheCommand.getFreshApplication | train | protected function getFreshApplication()
{
return tap(require $this->laravel->bootstrapPath('app.php'), function ($app) {
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
});
} | php | {
"resource": ""
} |
q25635 | MediaFieldTransformer.getOptions | train | protected function getOptions(FieldTypeInterface $field)
{
$options = parent::getOptions($field);
$attachedFile = get_attached_file($field->getValue());
$options['media'] = [
'name' => wp_basename($attachedFile),
'thumbnail' => wp_get_attachment_image_src($field->ge... | php | {
"resource": ""
} |
q25636 | Url.toInternal | train | public static function toInternal(array $routeParams, $scheme = false)
{
if ($scheme) {
return Yii::$app->getUrlManager()->internalCreateAbsoluteUrl($routeParams);
}
return Yii::$app->getUrlManager()->internalCreateUrl($routeParams);
} | php | {
"resource": ""
} |
q25637 | Url.toAjax | train | public static function toAjax($route, array $params = [])
{
$routeParams = ['/'.$route];
foreach ($params as $key => $value) {
$routeParams[$key] = $value;
}
return static::toInternal($routeParams, true);
} | php | {
"resource": ""
} |
q25638 | HtmlEncodeBehavior.afterFind | train | public function afterFind($event)
{
foreach ($this->attributes as $attribute) {
$this->owner->{$attribute} = $this->htmlEncode($this->owner->{$attribute});
}
} | php | {
"resource": ""
} |
q25639 | DurationValue.timeToIso8601Duration | train | protected function timeToIso8601Duration($time)
{
$units = array(
"Y" => 365*24*3600,
"D" => 24*3600,
"H" => 3600,
"M" => 60,
"S" => 1,
);
$str = "P";
$istime = false;
... | php | {
"resource": ""
} |
q25640 | RegistryTrait.has | train | public static function has($name)
{
return (self::find()->where([self::getNameAttribute() => $name])->one()) ? true : false;
} | php | {
"resource": ""
} |
q25641 | RegistryTrait.get | train | public static function get($name, $defaultValue = null)
{
$model = self::find()->where([self::getNameAttribute() => $name])->asArray()->one();
if ($model) {
return $model[self::getValueAttribute()];
}
return $defaultValue;
} | php | {
"resource": ""
} |
q25642 | RegistryTrait.remove | train | public static function remove($name)
{
$model = self::find()->where([self::getNameAttribute() => $name])->one();
if ($model) {
return (bool) $model->delete();
}
return false;
} | php | {
"resource": ""
} |
q25643 | ResponseCache.callActionCallable | train | private function callActionCallable($action, $result)
{
if (isset($this->actionsCallable[$action]) && is_callable($this->actionsCallable[$action])) {
call_user_func($this->actionsCallable[$action], $result);
}
} | php | {
"resource": ""
} |
q25644 | TextValue.truncate | train | public function truncate($length)
{
$this->_text = StringHelper::truncate($this->_text, $length);
return $this;
} | php | {
"resource": ""
} |
q25645 | Controller.getViewPath | train | public function getViewPath()
{
if ($this->module instanceof Module) {
if ($this->module->useAppViewPath) {
return '@app/views/' . $this->module->id . '/' . $this->id;
} elseif (is_array($this->module->viewMap)) {
$currentAction = $this->id . '/' . ($t... | php | {
"resource": ""
} |
q25646 | Controller.render | train | public function render($view, $params = [])
{
if (!empty($this->module->context) && empty($this->layout)) {
return $this->renderPartial($view, $params);
}
return parent::render($view, $params);
} | php | {
"resource": ""
} |
q25647 | Bootstrap.beforeRun | train | public function beforeRun($app)
{
foreach ($app->tags as $name => $config) {
TagParser::inject($name, $config);
}
foreach ($this->getModules() as $id => $module) {
foreach ($module->urlRules as $key => $rule) {
if (is_string($key)) {
... | php | {
"resource": ""
} |
q25648 | Bootstrap.run | train | public function run($app)
{
if (!$app->request->getIsConsoleRequest()) {
if ($this->hasModule('admin') && $app->request->isAdmin) {
// When admin context, change csrf token, this will not terminate the frontend csrf token:
// @see https://github.com/luyadev/luya/i... | php | {
"resource": ""
} |
q25649 | Rating.getRatingValue | train | public function getRatingValue()
{
if ($this->_ratingValue === null) {
return null;
}
$range = new RangeValue($this->_ratingValue);
$range->ensureRange($this->_worstRating ?: 0, $this->_bestRating ?: 5);
return $this->_ratingValue = $range->getValue();
} | php | {
"resource": ""
} |
q25650 | RobotsFilter.setRenderTime | train | protected function setRenderTime($time)
{
$merge = Yii::$app->session->get(self::ROBOTS_FILTER_SESSION_IDENTIFIER, []);
Yii::$app->session->set(self::ROBOTS_FILTER_SESSION_IDENTIFIER, array_merge([$this->getSessionKeyByOwner() => $time], $merge));
} | php | {
"resource": ""
} |
q25651 | RobotsFilter.getSessionKeyByOwner | train | protected function getSessionKeyByOwner()
{
if ($this->sessionKey) {
return $this->sessionKey;
}
if ($this->owner instanceof Controller) {
return $this->owner->module->id;
}
return 'generic';
} | php | {
"resource": ""
} |
q25652 | StringHelper.typeCast | train | public static function typeCast($string)
{
if (is_numeric($string)) {
return static::typeCastNumeric($string);
} elseif (is_array($string)) {
return ArrayHelper::typeCast($string);
}
return $string;
} | php | {
"resource": ""
} |
q25653 | StringHelper.typeCastNumeric | train | public static function typeCastNumeric($value)
{
if (!self::isFloat($value)) {
return $value;
}
if (intval($value) == $value) {
return (int) $value;
}
return (float) $value;
} | php | {
"resource": ""
} |
q25654 | StringHelper.contains | train | public static function contains($needle, $haystack, $strict = false)
{
$needles = (array) $needle;
$state = false;
foreach ($needles as $item) {
$state = (strpos($haystack, $item) !== false);
if ($strict && !$state) {
ret... | php | {
"resource": ""
} |
q25655 | StringHelper.minify | train | public static function minify($content, array $options = [])
{
$min = preg_replace(['/[\n\r]/', '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s', ], ['', '>', '<', '\\1'], trim($content));
$min = str_replace(['> <'], ['><'], $min);
if (ArrayHelper::getValue($options, 'comments', false)) {... | php | {
"resource": ""
} |
q25656 | StringHelper.highlightWord | train | public static function highlightWord($content, $word, $markup = '<b>%s</b>')
{
$word = (array) $word;
$content = strip_tags($content);
$latest = null;
foreach ($word as $needle) {
preg_match_all("/".preg_quote($needle, '/')."+/i", $content, $matches);
if (is_a... | php | {
"resource": ""
} |
q25657 | StringHelper.mb_str_split | train | public static function mb_str_split($string, $length = 1)
{
$array = [];
$stringLength = mb_strlen($string, 'UTF-8');
for ($i = 0; $i < $stringLength; $i += $length) {
$array[] = mb_substr($string, $i, $length, 'UTF-8');
}
return $array;
} | php | {
"resource": ""
} |
q25658 | EventTrait.setAttendee | train | public function setAttendee($attendee)
{
ObjectHelper::isInstanceOf($attendee, [Organization::class, PersonInterface::class]);
$this->_attendee = $attendee;
return $this;
} | php | {
"resource": ""
} |
q25659 | EventTrait.setComposer | train | public function setComposer($composer)
{
ObjectHelper::isInstanceOf($author, [Organization::class, PersonInterface::class]);
$this->_composer = $composer;
return $this;
} | php | {
"resource": ""
} |
q25660 | EventTrait.setContributor | train | public function setContributor($contributor)
{
ObjectHelper::isInstanceOf($contributor, [Organization::class, PersonInterface::class]);
$this->_contributor = $contributor;
return $this;
} | php | {
"resource": ""
} |
q25661 | EventTrait.setOrganizer | train | public function setOrganizer($organizer)
{
ObjectHelper::isInstanceOf($organizer, [Organization::class, PersonInterface::class]);
$this->_organizer = $organizer;
return $this;
} | php | {
"resource": ""
} |
q25662 | EventTrait.setTranslator | train | public function setTranslator($translator)
{
ObjectHelper::isInstanceOf($translator, [Organization::class, PersonInterface::class]);
$this->_translator = $translator;
return $this;
} | php | {
"resource": ""
} |
q25663 | Bootstrap.run | train | public function run($app)
{
foreach ($app->getApplicationModules() as $id => $module) {
$folder = $module->basePath . DIRECTORY_SEPARATOR . 'commands';
if (file_exists($folder) && is_dir($folder)) {
foreach (FileHelper::findFiles($folder) as $file) {
... | php | {
"resource": ""
} |
q25664 | BaseDevCommand.actionConfigInfo | train | public function actionConfigInfo()
{
$this->outputInfo("dev config file: " . Yii::getAlias($this->configFile));
$config = $this->readConfig();
if (!$config) {
return $this->outputError("Unable to open config file.");
}
foreach ($config a... | php | {
"resource": ""
} |
q25665 | BaseDevCommand.readConfig | train | protected function readConfig()
{
$data = FileHelper::getFileContent($this->configFile);
if ($data) {
return Json::decode($data);
}
return false;
} | php | {
"resource": ""
} |
q25666 | BaseDevCommand.getConfig | train | protected function getConfig($key, $defaultValue = null)
{
$config = $this->readConfig();
return isset($config[$key]) ? $config[$key] : $defaultValue;
} | php | {
"resource": ""
} |
q25667 | BaseDevCommand.saveConfig | train | protected function saveConfig($key, $value)
{
$content = $this->readConfig();
if (!$content) {
$content = [];
}
$content[$key] = $value;
$save = FileHelper::writeFile($this->configFile, Json::encode($content));
if (!$save) ... | php | {
"resource": ""
} |
q25668 | View.init | train | public function init()
{
// call parent initializer
parent::init();
// auto register csrf tags if enabled
if ($this->autoRegisterCsrf && Yii::$app->request->enableCsrfValidation) {
$this->registerCsrfMetaTags();
}
} | php | {
"resource": ""
} |
q25669 | View.getAssetUrl | train | public function getAssetUrl($assetName)
{
$assetName = ltrim($assetName, '\\');
if (!isset($this->assetBundles[$assetName])) {
throw new Exception("The AssetBundle '$assetName' is not registered.");
}
return $this->assetBundles[$assetName]->baseUrl;
... | php | {
"resource": ""
} |
q25670 | EmailLink.setEmail | train | public function setEmail($email)
{
$validator = new EmailValidator();
if ($validator->validate($email)) {
$this->_email = $email;
} else {
$this->_email = false;
}
} | php | {
"resource": ""
} |
q25671 | HealthController.actionIndex | train | public function actionIndex()
{
$error = false;
@chdir(Yii::getAlias('@app'));
$this->output('The directory the health commands is applying to: ' . Yii::getAlias('@app'));
foreach ($this->folders as $folder => $writable) {
$mode = ($writable) ? 0777 : 0775;
... | php | {
"resource": ""
} |
q25672 | JsonLd.addGraph | train | public static function addGraph($data)
{
self::registerView();
if (is_scalar($data)) {
throw new Exception("Data must be either an array or an object of type luya\web\jsonld\BaseThing.");
}
Yii::$app->view->params['@context'] = 'https://schema.org';
... | php | {
"resource": ""
} |
q25673 | JsonLd.registerView | train | protected static function registerView()
{
if (self::$_view === null) {
Yii::$app->view->on(View::EVENT_BEGIN_BODY, function ($event) {
echo '<script type="application/ld+json">' . Json::encode($event->sender->params) . '</script>';
});
... | php | {
"resource": ""
} |
q25674 | FloatValidator.validateAttribute | train | public function validateAttribute($model, $attribute)
{
$value = $model->$attribute;
if (!is_numeric($value) && !is_float($value)) {
return $model->addError($attribute, Yii::t('luya', $this->message, ['attribute' => $model->getAttributeLabel($attribute)]));
}
} | php | {
"resource": ""
} |
q25675 | TelTag.parse | train | public function parse($value, $sub)
{
return Html::a(empty($sub) ? $value : $sub, 'tel:' . $this->ensureNumber($value));
} | php | {
"resource": ""
} |
q25676 | WebsiteLink.setHref | train | public function setHref($href)
{
if (StringHelper::startsWith($href, '//')) {
$this->_href = Url::base(true) . str_replace('//', '/', $href);
} else {
$this->_href = Url::ensureHttp($href);
}
} | php | {
"resource": ""
} |
q25677 | Json.isJson | train | public static function isJson($value)
{
if (!is_scalar($value)) {
return false;
}
$firstChar = substr($value, 0, 1);
if ($firstChar !== '{' && $firstChar !== '[') {
return false;
}
$json_check = json_decode($... | php | {
"resource": ""
} |
q25678 | RepoController.actionUpdate | train | public function actionUpdate()
{
foreach ($this->repos as $repo) {
$this->rebaseRepo($repo, $this->getFilesystemRepoPath($repo));
}
foreach ($this->getConfig(self::CONFIG_VAR_CUSTOMCLONES, []) as $repo => $path) {
$this->rebaseRepo($repo, $path);
}
... | php | {
"resource": ""
} |
q25679 | RepoController.actionRemove | train | public function actionRemove($repo)
{
FileHelper::removeDirectory($this->getFilesystemRepoPath($repo));
$clones = $this->getConfig(self::CONFIG_VAR_CUSTOMCLONES, []);
if (isset($clones[$repo])) {
unset($clones[$repo]);
$this->saveConfig(self::CONFIG_VAR_CUSTOMCLONES, ... | php | {
"resource": ""
} |
q25680 | Hook.on | train | public static function on($name, $value, $prepend = false)
{
$object = new HookEvent(['handler' => $value]);
if ($prepend) {
array_unshift(static::$_hooks[$name], $object);
} else {
static::$_hooks[$name][] = $object;
}
} | php | {
"resource": ""
} |
q25681 | Hook.string | train | public static function string($name)
{
$buffer = [];
foreach (self::trigger($name) as $hook) {
$buffer[] = $hook->output;
}
return implode("", $buffer);
} | php | {
"resource": ""
} |
q25682 | Hook.iterate | train | public static function iterate($name)
{
$buffer = [];
foreach (self::trigger($name) as $hook) {
$buffer = array_merge($buffer, $hook->getIterations());
}
return $buffer;
} | php | {
"resource": ""
} |
q25683 | LinkTag.parse | train | public function parse($value, $sub)
{
if (substr($value, 0, 2) == '//') {
$value = StringHelper::replaceFirst('//', Url::base(true) . '/', $value);
$external = false;
} else {
$external = true;
}
$value = Url::ensureHttp($value);
$... | php | {
"resource": ""
} |
q25684 | ModuleController.renderReadme | train | public function renderReadme($folders, $name, $ns)
{
return $this->view->render('@luya/console/commands/views/module/readme.php', [
'folders' => $folders,
'name' => $name,
'humanName' => $this->humanizeName($name),
'ns' => $ns,
'luyaText' => $this-... | php | {
"resource": ""
} |
q25685 | Composition.isHostAllowed | train | public function isHostAllowed($allowedHosts)
{
$currentHost = $this->request->hostName;
$rules = (array) $allowedHosts;
foreach ($rules as $allowedHost) {
if (StringHelper::matchWildcard($allowedHost, $currentHost)) {
return true;
}
... | php | {
"resource": ""
} |
q25686 | Composition.getKeys | train | public function getKeys()
{
if ($this->_keys === null) {
$this->_keys = $this->getResolvedPathInfo($this->request)->resolvedValues;
}
return $this->_keys;
} | php | {
"resource": ""
} |
q25687 | Composition.getKey | train | public function getKey($key, $defaultValue = false)
{
$this->getKeys();
return isset($this->_keys[$key]) ? $this->_keys[$key] : $defaultValue;
} | php | {
"resource": ""
} |
q25688 | Composition.createRouteEnsure | train | public function createRouteEnsure(array $overrideKeys = [])
{
if (isset($overrideKeys['langShortCode'])) {
$langShortCode = $overrideKeys['langShortCode'];
} else {
$langShortCode = $this->langShortCode;
}
return $this->hidden || (!$this->hidden && $langShortC... | php | {
"resource": ""
} |
q25689 | Boot.getIsCli | train | public function getIsCli()
{
if ($this->_isCli === null) {
$this->_isCli = $this->getSapiName() === 'cli';
}
return $this->_isCli;
} | php | {
"resource": ""
} |
q25690 | Boot.getConfigArray | train | public function getConfigArray()
{
if ($this->_configArray === null) {
if (!file_exists($this->configFile)) {
if (!$this->getIsCli()) {
throw new Exception("Unable to load the config file '".$this->configFile."'.");
}
... | php | {
"resource": ""
} |
q25691 | Boot.applicationConsole | train | public function applicationConsole()
{
$this->setIsCli(true);
$config = $this->getConfigArray();
$config['defaultRoute'] = 'help';
if (isset($config['components'])) {
if (isset($config['components']['composition'])) {
unset($config['components']['compositi... | php | {
"resource": ""
} |
q25692 | Boot.applicationWeb | train | public function applicationWeb()
{
$config = $this->getConfigArray();
$this->includeYii();
$mergedConfig = ArrayHelper::merge($config, ['bootstrap' => ['luya\web\Bootstrap']]);
$this->app = new WebApplication($mergedConfig);
if (!$this->mockOnly) {
return $this->a... | php | {
"resource": ""
} |
q25693 | Boot.includeYii | train | private function includeYii()
{
if (file_exists($this->_baseYiiFile)) {
defined('LUYA_YII_VENDOR') ?: define('LUYA_YII_VENDOR', dirname($this->_baseYiiFile));
$baseYiiFolder = LUYA_YII_VENDOR . DIRECTORY_SEPARATOR;
$luyaYiiFile = $this->getCoreBasePath() . DI... | php | {
"resource": ""
} |
q25694 | Widget.getViewPath | train | public function getViewPath()
{
if (!$this->useAppViewPath) {
return parent::getViewPath();
}
// get reflection
$class = new ReflectionClass($this);
// get path with alias
return '@app/views/widgets/' . Inflector::camel2id($class->getShortName());... | php | {
"resource": ""
} |
q25695 | NextPrevModel.getPrev | train | public function getPrev()
{
return self::find()->where(['<', 'id', $this->id])->orderBy(['id' => SORT_DESC])->limit(1)->one();
} | php | {
"resource": ""
} |
q25696 | ApplicationTrait.init | train | public function init()
{
parent::init();
// add trace info
Yii::trace('initialize LUYA Application', __METHOD__);
$this->setLocale($this->language);
} | php | {
"resource": ""
} |
q25697 | ApplicationTrait.getPackageInstaller | train | public function getPackageInstaller()
{
$file = Yii::getAlias('@vendor/luyadev/installer.php');
$data = is_file($file) ? include $file : [];
return new PackageInstaller($data);
} | php | {
"resource": ""
} |
q25698 | ApplicationTrait.getApplicationModules | train | public function getApplicationModules()
{
$modules = [];
foreach ($this->getModules() as $id => $obj) {
if ($obj instanceof Module) {
$modules[$id] = $obj;
}
}
return $modules;
} | php | {
"resource": ""
} |
q25699 | ApplicationTrait.getFrontendModules | train | public function getFrontendModules()
{
$modules = [];
foreach ($this->getModules() as $id => $obj) {
if ($obj instanceof Module && !$obj instanceof AdminModuleInterface && !$obj instanceof CoreModuleInterface) {
$modules[$id] = $obj;
}
}
retu... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.