_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q25700 | ApplicationTrait.getAdminModules | train | public function getAdminModules()
{
$modules = [];
foreach ($this->getModules() as $id => $obj) {
if ($obj instanceof Module && $obj instanceof AdminModuleInterface) {
$modules[$id] = $obj;
}
}
return $modules;
} | php | {
"resource": ""
} |
q25701 | Element.init | train | public function init()
{
$path = Yii::getAlias($this->configFile);
if (file_exists($path)) {
$config = (include($path));
foreach ($config as $name => $closure) {
if (is_array($closure)) {
$this->addElement($name, $closure[0], $closure[1]);
... | php | {
"resource": ""
} |
q25702 | Element.addElement | train | public function addElement($name, $closure, $mockedArgs = [])
{
$this->_elements[$name] = $closure;
$this->mockArgs($name, $mockedArgs);
} | php | {
"resource": ""
} |
q25703 | Element.getElement | train | public function getElement($name, array $params = [])
{
if (!array_key_exists($name, $this->_elements)) {
throw new Exception("The requested element '$name' does not exist in the list. You may register the element first with `addElement(name, closure)`.");
}
return call_user... | php | {
"resource": ""
} |
q25704 | Element.getMockedArgValue | train | public function getMockedArgValue($elementName, $argName)
{
if (isset($this->_mockedArguments[$elementName]) && isset($this->_mockedArguments[$elementName][$argName])) {
$response = $this->_mockedArguments[$elementName][$argName];
if (is_callable($response)) {
$respon... | php | {
"resource": ""
} |
q25705 | Element.render | train | public function render($file, array $args = [])
{
$view = new View();
$view->autoRegisterCsrf = false;
return $view->renderPhpFile(rtrim($this->getFolder(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . FileHelper::ensureExtension($file, 'php'), $args);
} | php | {
"resource": ""
} |
q25706 | BaseThing.resolveGetterMethods | train | public function resolveGetterMethods()
{
$resolved = [];
$methods = get_class_methods($this);
if (!$methods) {
return [];
}
foreach ($methods as $method) {
if (StringHelper::startsWith($method, 'get', true)) {
$resolve... | php | {
"resource": ""
} |
q25707 | BaseThing.removeEmptyValues | train | private function removeEmptyValues(array $haystack)
{
foreach ($haystack as $key => $value) {
if (is_array($value)) {
$haystack[$key] = $this->removeEmptyValues($value);
}
// remove empty values value value is NULL or an empty string ''
if ($va... | php | {
"resource": ""
} |
q25708 | TimestampBehavior.beforeInsert | train | public function beforeInsert($event)
{
foreach ($this->insert as $field) {
$event->sender->$field = time();
}
} | php | {
"resource": ""
} |
q25709 | TimestampBehavior.beforeUpdate | train | public function beforeUpdate($event)
{
foreach ($this->update as $field) {
$event->sender->$field = time();
}
} | php | {
"resource": ""
} |
q25710 | ImportHelper.csv | train | public static function csv($filename, array $options = [])
{
$filename = Yii::getAlias($filename);
// check if a given file name is provided or a csv based on the content
if (FileHelper::getFileInfo($filename)->extension) {
$resource = fopen($filename, 'r');
} el... | php | {
"resource": ""
} |
q25711 | BaseBootstrap.extractModules | train | public function extractModules($app)
{
if ($this->_modules === null) {
foreach ($app->getModules() as $id => $obj) {
// create module object
$moduleObject = Yii::$app->getModule($id);
// see if the module is a luya base module, otherwise ignore
... | php | {
"resource": ""
} |
q25712 | ImportController.addToDirectory | train | protected function addToDirectory($path, $folderName, $ns, $module)
{
if (file_exists($path)) {
$this->_dirs[$folderName][] = [
'ns' => $ns,
'module' => $module,
'folderPath' => $path.DIRECTORY_SEPARATOR,
'files' => $this->scanDirec... | php | {
"resource": ""
} |
q25713 | ImportController.scanDirectoryFiles | train | protected function scanDirectoryFiles($path, $ns, $module)
{
$files = [];
foreach (scandir($path) as $file) {
if (substr($file, 0, 1) !== '.') {
$files[] = [
'file' => $file,
'module' => $module,
'ns' => $ns.'\\'... | php | {
"resource": ""
} |
q25714 | ImportController.buildImporterQueue | train | public function buildImporterQueue()
{
$queue = [];
foreach (Yii::$app->getApplicationModules() as $id => $module) {
$response = $module->import($this);
// if there response is an array, the it will be added to the queue
if (is_array($response)) {
... | php | {
"resource": ""
} |
q25715 | ImportController.actionIndex | train | public function actionIndex()
{
$queue = $this->buildImporterQueue();
foreach ($queue as $pos => $object) {
$this->verbosePrint("Run importer object '{$object->className()}' on position '{$pos}'.", __METHOD__);
$this->verbosePrint('Module context id: ' . $object->module->id)... | php | {
"resource": ""
} |
q25716 | ImportController.logValueToTable | train | private function logValueToTable(array $logs)
{
$table = new Table();
$table->setHeaders(['Key', 'Value']);
$rows = [];
foreach ($logs as $key => $value) {
if (is_array($value)) {
foreach ($value as $kk => $kv) {
$rows[] = [$kk, $... | php | {
"resource": ""
} |
q25717 | Controller.output | train | protected function output($message, $color = null)
{
$format = [];
if (!$this->isMuted()) {
if ($color !== null) {
$format[] = $color;
}
echo Console::ansiFormat("\r".$message."\n", $format);
}
} | php | {
"resource": ""
} |
q25718 | TagParser.getInstantiatedTagObjects | train | public static function getInstantiatedTagObjects()
{
$context = self::getInstance();
foreach ($context->tags as $key => $config) {
$context->instantiatTag($key);
}
return $context->tags;
} | php | {
"resource": ""
} |
q25719 | TagParser.parseTag | train | private function parseTag($tag, $context)
{
// ensure tag is an object
$this->instantiatTag($tag);
// extract context
$value = isset($context['value']) ? $context['value'] : false;
$sub = isset($context['sub']) ? $context['sub'] : false;
// the sub value can contain e... | php | {
"resource": ""
} |
q25720 | TagParser.processText | train | private function processText($text)
{
// verify if content is a string otherwhise just return the original provided content
if (!is_string($text) || empty($text)) {
return $text;
}
// find all tags based on the REGEX expression
preg_match_all(static::REGEX, $text,... | php | {
"resource": ""
} |
q25721 | CacheableTrait.isCachable | train | public function isCachable()
{
if ($this->_cachable === null) {
$this->_cachable = Yii::$app->has('cache') ? true : false;
}
return $this->_cachable;
} | php | {
"resource": ""
} |
q25722 | CacheableTrait.setHasCache | train | public function setHasCache($key, $value, $dependency = null, $cacheExpiration = null)
{
if ($this->isCachable()) {
if (is_array($dependency)) {
$dependency = Yii::createObject($dependency);
}
return Yii::$app->cache->set($key, $value, is_null... | php | {
"resource": ""
} |
q25723 | CacheableTrait.deleteHasCache | train | public function deleteHasCache($key)
{
if ($this->isCachable()) {
return Yii::$app->cache->delete($key);
}
return false;
} | php | {
"resource": ""
} |
q25724 | CacheableTrait.getHasCache | train | public function getHasCache($key)
{
if ($this->isCachable()) {
$data = Yii::$app->cache->get($key);
$enumKey = (is_array($key)) ? implode(",", $key) : $key;
if ($data) {
Yii::debug("Cacheable trait key '$enumKey' successfully load... | php | {
"resource": ""
} |
q25725 | Mail.getMailer | train | public function getMailer()
{
if ($this->_mailer === null) {
$this->_mailer = new PHPMailer();
$this->_mailer->CharSet = 'UTF-8';
$this->_mailer->From = $this->from;
$this->_mailer->FromName = $this->fromName;
$this->_mailer->isHTML(true);
... | php | {
"resource": ""
} |
q25726 | Mail.compose | train | public function compose($subject = null, $body = null)
{
$this->cleanup();
if ($subject !== null) {
$this->subject($subject);
}
if ($body !== null) {
$this->body($body);
}
return $this;
} | php | {
"resource": ""
} |
q25727 | Mail.body | train | public function body($body)
{
$message = $this->wrapLayout($body);
$this->getMailer()->Body = $message;
$alt = empty($this->altBody) ? $this->convertMessageToAltBody($message) : $this->altBody;
$this->getMailer()->AltBody = $alt;
return $this;
} | php | {
"resource": ""
} |
q25728 | Mail.convertMessageToAltBody | train | public function convertMessageToAltBody($message)
{
$message = preg_replace('/<head>(.*?)<\/head>/s', '', $message);
$tags = ['</p>', '<br />', '<br>', '<hr />', '<hr>', '</h1>', '</h2>', '</h3>', '</h4>', '</h5>', '</h6>'];
return trim(strip_tags(str_replace($tags, PHP_EOL, $message)));
... | php | {
"resource": ""
} |
q25729 | Mail.render | train | public function render($viewFile, array $params = [])
{
$this->body(Yii::$app->view->render($viewFile, $params));
return $this;
} | php | {
"resource": ""
} |
q25730 | Mail.addresses | train | public function addresses(array $emails)
{
foreach ($emails as $name => $mail) {
if (is_int($name)) {
$this->address($mail);
} else {
$this->address($mail, $name);
}
}
return $this;
} | php | {
"resource": ""
} |
q25731 | Mail.address | train | public function address($email, $name = null)
{
$this->getMailer()->addAddress($email, (empty($name)) ? $email : $name);
return $this;
} | php | {
"resource": ""
} |
q25732 | Mail.ccAddresses | train | public function ccAddresses(array $emails)
{
foreach ($emails as $name => $mail) {
if (is_int($name)) {
$this->ccAddress($mail);
} else {
$this->ccAddress($mail, $name);
}
}
return $this;
} | php | {
"resource": ""
} |
q25733 | Mail.ccAddress | train | public function ccAddress($email, $name = null)
{
$this->getMailer()->addCC($email, (empty($name)) ? $email : $name);
return $this;
} | php | {
"resource": ""
} |
q25734 | Mail.bccAddresses | train | public function bccAddresses(array $emails)
{
foreach ($emails as $name => $mail) {
if (is_int($name)) {
$this->bccAddress($mail);
} else {
$this->bccAddress($mail, $name);
}
}
return $this;
} | php | {
"resource": ""
} |
q25735 | Mail.bccAddress | train | public function bccAddress($email, $name = null)
{
$this->getMailer()->addBCC($email, (empty($name)) ? $email : $name);
return $this;
} | php | {
"resource": ""
} |
q25736 | Mail.addAttachment | train | public function addAttachment($filePath, $name = null)
{
$this->getMailer()->addAttachment($filePath, empty($name) ? pathinfo($filePath, PATHINFO_BASENAME) : $name);
return $this;
} | php | {
"resource": ""
} |
q25737 | Mail.addReplyTo | train | public function addReplyTo($email, $name = null)
{
$this->getMailer()->addReplyTo($email, empty($name) ? $email : $name);
return $this;
} | php | {
"resource": ""
} |
q25738 | Mail.send | train | public function send()
{
if (empty($this->mailer->Subject) || empty($this->mailer->Body)) {
throw new Exception("Mail subject() and body() can not be empty in order to send mail.");
}
if (!$this->getMailer()->send()) {
Yii::error($this->getError(), __METHOD__);
... | php | {
"resource": ""
} |
q25739 | RestBehaviorsTrait.getUserAuthClass | train | private function getUserAuthClass()
{
if ($this instanceof UserBehaviorInterface) {
$class = $this->userAuthClass();
if (!$class) { // return false;
return false;
}
if (!is_object($class)) {
return Yii:... | php | {
"resource": ""
} |
q25740 | RestBehaviorsTrait.sendModelError | train | public function sendModelError(Model $model)
{
if (!$model->hasErrors()) {
throw new InvalidParamException('The model as thrown an uknown Error.');
}
Yii::$app->response->setStatusCode(422, 'Data Validation Failed.');
$result = [];
foreach ($model->getFir... | php | {
"resource": ""
} |
q25741 | RestBehaviorsTrait.sendArrayError | train | public function sendArrayError(array $errors)
{
Yii::$app->response->setStatusCode(422, 'Data Validation Failed.');
$result = [];
foreach ($errors as $key => $value) {
$messages = (array) $value;
foreach ($messages as $msg) {
$result[] = [... | php | {
"resource": ""
} |
q25742 | MailTag.parse | train | public function parse($value, $sub)
{
$label = $sub ?: $value;
// if obfuscation is enabled generate tag string due to yii tag method will encode attributes.
if ($this->obfuscate) {
if (!$sub) {
$label = $this->obfuscate($label);
}
return ... | php | {
"resource": ""
} |
q25743 | MailTag.obfuscate | train | public function obfuscate($email)
{
$output = null;
for ($i = 0; $i < strlen($email); $i++) {
$output .= '&#'.ord($email[$i]).';';
}
return $output;
} | php | {
"resource": ""
} |
q25744 | Formatter.autoFormat | train | public function autoFormat($value)
{
// email validation
if ((new EmailValidator())->validate($value)) {
return $this->asEmail($value);
}
// url validator
if ((new UrlValidator())->validate($value)) {
return $this->asUrl($value);
}
... | php | {
"resource": ""
} |
q25745 | ExportHelper.csv | train | public static function csv($input, array $keys = [], $header = true)
{
$delimiter = ",";
$input = self::transformInput($input);
$array = self::generateContentArray($input, $keys, $header);
return self::generateOutputString($array, $delimiter);
} | php | {
"resource": ""
} |
q25746 | ExportHelper.xlsx | train | public static function xlsx($input, array $keys = [], $header = true)
{
$input = self::transformInput($input);
$array = self::generateContentArray($input, $keys, $header);
$writer = new XLSXWriter();
$writer->writeSheet($array);
return $writer->writeToString();
} | php | {
"resource": ""
} |
q25747 | ExportHelper.generateContentArray | train | protected static function generateContentArray($contentRows, $keys, $generateHeader = true)
{
if (is_scalar($contentRows)) {
throw new Exception("Content must be either an array, object or traversable");
}
$attributeKeys = $keys;
$header = [];
$rows = [];
... | php | {
"resource": ""
} |
q25748 | ExportHelper.generateRow | train | protected static function generateRow(array $row, $delimiter, $enclose)
{
array_walk($row, function (&$item) use ($enclose) {
if (is_bool($item)) {
$item = (int) $item;
} elseif (is_null($item)) {
$item = '';
} elseif (!is_scalar($item)) {
... | php | {
"resource": ""
} |
q25749 | TelephoneLink.setTelephone | train | public function setTelephone($telephone)
{
/**
* Hack to support leading + sign
* @see \luya\cms\models\NavItemPageBlockItem::rules()
* @link https://github.com/luyadev/luya/pull/1815
*/
$telephone = ltrim($telephone, '\\');
$validator = new RegularExpres... | php | {
"resource": ""
} |
q25750 | ErrorHandlerTrait.transferMessage | train | public function transferMessage($message, $file = __FILE__, $line = __LINE__)
{
return $this->apiServerSendData($this->getExceptionArray([
'message' => $message,
'file' => $file,
'line' => $line,
]));
} | php | {
"resource": ""
} |
q25751 | ErrorHandlerTrait.apiServerSendData | train | private function apiServerSendData(array $data)
{
if ($this->transferException) {
$curl = new Curl();
$curl->setOpt(CURLOPT_CONNECTTIMEOUT, 2);
$curl->setOpt(CURLOPT_TIMEOUT, 2);
$curl->post(Url::ensureHttp(rtrim($this->api, '/')).'/create', [
... | php | {
"resource": ""
} |
q25752 | ErrorHandlerTrait.getExceptionArray | train | public function getExceptionArray($exception)
{
$_message = 'Uknonwn exception object, not instance of \Exception.';
$_file = 'unknown';
$_line = 0;
$_trace = [];
$_previousException = [];
if (is_object($exception)) {
$prev = $exception->getPrevio... | php | {
"resource": ""
} |
q25753 | ErrorHandlerTrait.buildTrace | train | private function buildTrace($exception)
{
$_trace = [];
foreach ($exception->getTrace() as $key => $item) {
$_trace[$key] = [
'file' => isset($item['file']) ? $item['file'] : null,
'line' => isset($item['line']) ? $item['line'] : null,
'fun... | php | {
"resource": ""
} |
q25754 | Request.getIsAdmin | train | public function getIsAdmin()
{
if ($this->_isAdmin === null) {
if ($this->getIsConsoleRequest() && !$this->forceWebRequest && !Yii::$app->hasModule('admin')) {
$this->_isAdmin = false;
} else {
// if there is only an application with admin module and s... | php | {
"resource": ""
} |
q25755 | Command.verbosePrint | train | public function verbosePrint($message, $section = null)
{
if ($this->verbose) {
$this->output((!empty($section)) ? $section . ': ' . $message : $message);
}
} | php | {
"resource": ""
} |
q25756 | Command.selectModule | train | public function selectModule(array $options = [])
{
$modules = [];
foreach (Yii::$app->getModules() as $id => $object) {
if (!$object instanceof \luya\base\Module) {
continue;
}
if (isset($options['onlyAdmin']) && $options['onlyAdmin']) {
... | php | {
"resource": ""
} |
q25757 | Command.createClassName | train | public function createClassName($string, $suffix = false)
{
$name = Inflector::camelize($string);
if ($suffix !== false && StringHelper::endsWith($name, $suffix, false)) {
$name = substr($name, 0, -(strlen($suffix)));
}
return $name . $suffix;
} | php | {
"resource": ""
} |
q25758 | BaseCrudController.getSqlTablesArray | train | public function getSqlTablesArray()
{
$names = Yii::$app->db->schema->tableNames;
return array_combine($names, $names);
} | php | {
"resource": ""
} |
q25759 | BaseCrudController.isColumnAutoIncremental | train | protected function isColumnAutoIncremental($table, $columns)
{
foreach ($columns as $column) {
if (isset($table->columns[$column]) && $table->columns[$column]->autoIncrement) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q25760 | JsonBehavior.autoEncodeAttributes | train | public function autoEncodeAttributes()
{
foreach ($this->attributes as $name) {
if (!isset($this->owner->getDirtyAttributes()[$name])) {
continue;
}
$value = $this->owner->{$name};
if (is_array($value)) {
... | php | {
"resource": ""
} |
q25761 | ArrayHelper.coverSensitiveValues | train | public static function coverSensitiveValues(array $data, array $keys = [])
{
if (empty($keys)) {
$keys = self::$sensitiveDefaultKeys;
}
$clean = [];
foreach ($keys as $key) {
$kw = strtolower($key);
foreach ($data as $k => $v) {
... | php | {
"resource": ""
} |
q25762 | ArrayHelper.arrayUnshiftAssoc | train | public static function arrayUnshiftAssoc(&$arr, $key, $val)
{
$arr = array_reverse($arr, true);
$arr[$key] = $val;
return array_reverse($arr, true);
} | php | {
"resource": ""
} |
q25763 | ArrayHelper.typeCast | train | public static function typeCast(array $array)
{
$return = [];
foreach ($array as $k => $v) {
if (is_numeric($v)) {
$return[$k] = StringHelper::typeCastNumeric($v);
} elseif (is_array($v)) {
$return[$k] = self::typeCast($v);
... | php | {
"resource": ""
} |
q25764 | ArrayHelper.search | train | public static function search(array $array, $searchText, $sensitive = false)
{
$function = ($sensitive) ? 'strpos' : 'stripos';
return array_filter($array, function ($item) use ($searchText, $function) {
$response = false;
foreach ($item as $key => $value) {
i... | php | {
"resource": ""
} |
q25765 | ArrayHelper.searchColumn | train | public static function searchColumn(array $array, $column, $search)
{
$array = array_values($array); // align array keys
$columns = array_column($array, $column);
$key = array_search($search, $columns);
return ($key !== false) ? $array[$key] : false;
} | php | {
"resource": ""
} |
q25766 | ArrayHelper.searchColumns | train | public static function searchColumns(array $array, $column, $search)
{
$keys = array_filter($array, function ($var) use ($column, $search) {
return strcasecmp($search, $var[$column]) == 0 ? true : false;
});
return $keys;
} | php | {
"resource": ""
} |
q25767 | ArrayHelper.generateRange | train | public static function generateRange($from, $to, $text = null)
{
$range = range($from, $to);
$array = array_combine($range, $range);
if ($text) {
array_walk($array, function (&$item, $key) use ($text) {
if (is_array($text)) {
list($sin... | php | {
"resource": ""
} |
q25768 | FileHelper.classInfo | train | public static function classInfo($file)
{
if (is_file($file)) {
$phpCode = file_get_contents($file);
} else {
$phpCode = $file;
}
$namespace = false;
if (preg_match('/^namespace\s+(.+?);(\s+|\r\n)?$/sm', $phpCode, $results)) {
... | php | {
"resource": ""
} |
q25769 | FileHelper.classNameByTokens | train | private static function classNameByTokens($phpCode)
{
$classes = [];
$tokens = token_get_all($phpCode);
$count = count($tokens);
for ($i = 2; $i < $count; $i++) {
if ($tokens[$i - 2][0] == T_CLASS && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) {
... | php | {
"resource": ""
} |
q25770 | FileHelper.unlink | train | public static function unlink($file)
{
// no errors should be thrown, return false instead.
try {
if (parent::unlink($file)) {
return true;
}
} catch (\Exception $e) {}
// try to force symlinks
if (is_link($file)) {
... | php | {
"resource": ""
} |
q25771 | UrlManager.routeHasLanguageCompositionPrefix | train | public function routeHasLanguageCompositionPrefix($route, $language)
{
$parts = explode("/", $route);
if (isset($parts[0]) && $parts[0] == $language) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q25772 | UrlManager.getMenu | train | public function getMenu()
{
if ($this->_menu === null) {
$menu = Yii::$app->get('menu', false);
if ($menu) {
$this->_menu = $menu;
} else {
$this->_menu = false;
}
}
return $this->_menu;
} | php | {
"resource": ""
} |
q25773 | UrlManager.getComposition | train | public function getComposition()
{
if ($this->_composition === null) {
$this->_composition = Yii::$app->get('composition');
}
return $this->_composition;
} | php | {
"resource": ""
} |
q25774 | UrlManager.createUrl | train | public function createUrl($params)
{
$response = $this->internalCreateUrl($params);
if ($this->contextNavItemId) {
return $this->urlReplaceModule($response, $this->contextNavItemId, $this->getComposition());
}
return $response;
} | php | {
"resource": ""
} |
q25775 | UrlManager.createMenuItemUrl | train | public function createMenuItemUrl($params, $navItemId, $composition = null)
{
$composition = empty($composition) ? $this->getComposition() : $composition;
$url = $this->internalCreateUrl($params, $composition);
if (!$this->menu) {
return $url;
}
return $this->ur... | php | {
"resource": ""
} |
q25776 | UrlManager.internalCreateUrl | train | public function internalCreateUrl($params, $composition = null)
{
$params = (array) $params;
$composition = empty($composition) ? $this->getComposition() : $composition;
$originalParams = $params;
// prepand the original route, whether is hidden or not!
... | php | {
"resource": ""
} |
q25777 | UrlManager.internalCreateAbsoluteUrl | train | public function internalCreateAbsoluteUrl($params, $scheme = null)
{
$params = (array) $params;
$url = $this->internalCreateUrl($params);
if (strpos($url, '://') === false) {
$url = $this->getHostInfo() . $url;
}
if (is_string($scheme) && ($pos = strpos($url, '://... | php | {
"resource": ""
} |
q25778 | UrlManager.findModuleInRoute | train | private function findModuleInRoute($route)
{
$route = parse_url($route, PHP_URL_PATH);
$parts = array_values(array_filter(explode('/', $route)));
if (isset($parts[0]) && array_key_exists($parts[0], Yii::$app->getApplicationModules())) {
return $parts[0];
... | php | {
"resource": ""
} |
q25779 | UrlManager.urlReplaceModule | train | private function urlReplaceModule($url, $navItemId, Composition $composition)
{
$route = $composition->removeFrom($this->removeBaseUrl($url));
$moduleName = $this->findModuleInRoute($route);
if ($moduleName === false || $this->menu === false) {
return $url;
}
... | php | {
"resource": ""
} |
q25780 | ContactPoint.setAreaServed | train | public function setAreaServed($areaServed)
{
ObjectHelper::isInstanceOf($areaServed, [Place::class, TextValue::class]);
$this->_areaServed = $areaServed;
return $this;
} | php | {
"resource": ""
} |
q25781 | GroupUser.inGroup | train | public function inGroup($alias)
{
if ($this->isGuest) {
return false;
}
$identity = $this->identity;
if (!$identity instanceof GroupUserIdentityInterface) {
throw new InvalidConfigException('The $identityClass must be instance of luya\web\Gro... | php | {
"resource": ""
} |
q25782 | ObjectHelper.isTraitInstanceOf | train | public static function isTraitInstanceOf($object, $haystack)
{
$traits = static::traitsList($object);
// if its an object, the all traits for the given object.
if (is_object($haystack)) {
$haystack = static::traitsList($haystack);
}
foreach ((array) $haystack as... | php | {
"resource": ""
} |
q25783 | ObjectHelper.traitsList | train | public static function traitsList($object, $autoload = true)
{
$traits = [];
// Get traits of all parent classes
do {
$traits = array_merge(class_uses($object, $autoload), $traits);
} while ($object = get_parent_class($object));
// Get traits of all parent trait... | php | {
"resource": ""
} |
q25784 | ObjectHelper.callMethodSanitizeArguments | train | public static function callMethodSanitizeArguments($object, $method, array $argumentsList = [])
{
// get class reflection object
$reflection = new ReflectionMethod($object, $method);
// array where the sanitized arguemnts will be stored
$methodArgs = [];
foreach ($reflection... | php | {
"resource": ""
} |
q25785 | Module.resolveRoute | train | public function resolveRoute($route)
{
$routeParts = explode('/', $route);
foreach ($routeParts as $k => $v) {
if (($k == 0 && $v == $this->id) || (empty($v))) {
unset($routeParts[$k]);
}
}
if (count($routeParts) == 0) {
return $thi... | php | {
"resource": ""
} |
q25786 | Module.registerTranslation | train | public static function registerTranslation($prefix, $basePath, array $fileMap)
{
if (!isset(Yii::$app->i18n->translations[$prefix])) {
Yii::$app->i18n->translations[$prefix] = [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => $basePath,
'file... | php | {
"resource": ""
} |
q25787 | Module.baseT | train | public static function baseT($category, $message, array $params = [], $language = null)
{
static::onLoad();
return Yii::t($category, $message, $params, $language);
} | php | {
"resource": ""
} |
q25788 | ModuleReflection.setSuffix | train | public function setSuffix($suffix)
{
$this->_suffix = $suffix;
$this->request->setPathInfo(implode('/', [$this->module->id, $suffix]));
} | php | {
"resource": ""
} |
q25789 | ModuleReflection.getRequestRoute | train | public function getRequestRoute()
{
if ($this->_requestRoute !== null) {
return $this->_requestRoute;
}
if ($this->_defaultRoute !== null && empty($this->getSuffix())) {
$array = $this->_defaultRoute;
} else {
// parse request against urlM... | php | {
"resource": ""
} |
q25790 | ModuleReflection.defaultRoute | train | public function defaultRoute($controller, $action = null, array $args = [])
{
$this->_defaultRoute = [
'route' => implode('/', [$this->module->id, $controller, (empty($action)) ? 'index' : $action]),
'args' => $args,
'originalArgs' => $args,
];
} | php | {
"resource": ""
} |
q25791 | ModuleReflection.getUrlRule | train | public function getUrlRule()
{
$request = $this->getRequestRoute();
return [
'module' => $this->module->id,
'route' => $this->module->id . '/' . $request['route'],
'params' => $request['originalArgs'],
];
} | php | {
"resource": ""
} |
q25792 | ModuleReflection.run | train | public function run()
{
$requestRoute = $this->getRequestRoute();
// create controller object
$controller = $this->module->createController($requestRoute['route']);
// throw error if the requests request does not returns a valid controller object
if (!isset($controller[0]) &&... | php | {
"resource": ""
} |
q25793 | CompositionResolver.getResolvedKeyValue | train | public function getResolvedKeyValue($key)
{
$keys = $this->resolvedValues;
return isset($keys[$key]) ? $keys[$key] : false;
} | php | {
"resource": ""
} |
q25794 | CompositionResolver.getInternalResolverArray | train | protected function getInternalResolverArray()
{
if ($this->_resolved === null) {
$requestPathInfo = $this->trailingPathInfo();
$newRegex = $this->buildRegexPattern();
// extract the rules from the regex pattern, this means you get array with keys for every ru... | php | {
"resource": ""
} |
q25795 | CreativeWorkTrait.setAuthor | train | public function setAuthor($author)
{
ObjectHelper::isInstanceOf($author, [Organization::class, PersonInterface::class]);
$this->_author = $author;
return $this;
} | php | {
"resource": ""
} |
q25796 | CreativeWorkTrait.setCopyrightHolder | train | public function setCopyrightHolder($copyrightHolder)
{
ObjectHelper::isInstanceOf($copyrightHolder, [Organization::class, PersonInterface::class]);
$this->_copyrightHolder = $copyrightHolder;
return $this;
} | php | {
"resource": ""
} |
q25797 | CreativeWorkTrait.setPublisher | train | public function setPublisher($publisher)
{
ObjectHelper::isInstanceOf($publisher, [Organization::class, Person::class]);
$this->_publisher = $publisher;
return $this;
} | php | {
"resource": ""
} |
q25798 | Configuration.setAutoGenerateProxyClasses | train | public function setAutoGenerateProxyClasses(int $mode) : void
{
$this->autoGenerateProxyClasses = $mode;
$proxyManagerConfig = $this->getProxyManagerConfiguration();
switch ($mode) {
case self::AUTOGENERATE_FILE_NOT_EXISTS:
$proxyManagerConfig->setGen... | php | {
"resource": ""
} |
q25799 | Configuration.addFilter | train | public function addFilter(string $name, string $className, array $parameters = []) : void
{
$this->attributes['filters'][$name] = [
'class' => $className,
'parameters' => $parameters,
];
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.