_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q250400 | AbstractController.redirect | validation | protected function redirect($controller = null, $action = null)
{
if (null === $controller) {
$controller = Application::getInstance()->getDefaultController();
}
if (null === $action) {
$action = Application::getInstance()->getDefaultAction();
}
$desti... | php | {
"resource": ""
} |
q250401 | HttpHeadersTrait.adjustHeaders | validation | private function adjustHeaders($requestType)
{
if (! array_key_exists('Accept', $this->headers) && $requestType != 'HEAD') {
$this->setHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
}
if (! array_key_exists('Accept-Language', $this->... | php | {
"resource": ""
} |
q250402 | HttpHeadersTrait.addParsedHeader | validation | private function addParsedHeader($line)
{
if (strpos($line, ':') === false) {
$this->responseCode = HttpStatus::parseStatus($line)->getCode();
} else {
$line = trim($line);
list ($headerName, $headerValue) = explode(':', $line, 2);
$this->headers[$head... | php | {
"resource": ""
} |
q250403 | HttpHeadersTrait.adjustNumbytes | validation | private function adjustNumbytes($numBytes): int
{
if (isset($this->headers['Content-Length'])) {
// Try to read the whole payload at once
$numBytes = intval($this->headers['Content-Length']);
}
return $numBytes;
} | php | {
"resource": ""
} |
q250404 | HttpHeadersTrait.getHeader | validation | private function getHeader(string $name): string
{
$result = "";
if (Arrays::hasElement($this->headers, $name)) {
$result = $this->headers[$name];
}
return $result;
} | php | {
"resource": ""
} |
q250405 | XmlFileLoader.parseNode | validation | protected function parseNode(RuleCollection $collection, \DOMElement $node, $path, $file)
{
if (self::NAMESPACE_URI !== $node->namespaceURI) {
return;
}
switch ($node->localName) {
case 'rule':
$this->parseRule($collection, $node, $path);
... | php | {
"resource": ""
} |
q250406 | Prototype.fields | validation | public function fields($entity = array(), $action = 'all', array $params = array()) {
$fieldCollection = array();
$entity = $this->entityFactory->build($entity);
if ($entity instanceof \ElggEntity) {
$params['entity'] = $entity;
$fields = (array) elgg_trigger_plugin_hook('prototype', $action, $params, arr... | php | {
"resource": ""
} |
q250407 | Prototype.getValidationStatus | validation | public function getValidationStatus($action = '') {
$validation_status = null;
if (isset($_SESSION['prototyper_validation'][$action])) {
$validation_status = $_SESSION['prototyper_validation'][$action];
}
return $validation_status;
} | php | {
"resource": ""
} |
q250408 | Prototype.setFieldValidationStatus | validation | public function setFieldValidationStatus($action = '', $shortname = '', Elements\ValidationStatus $validation = null) {
if (!isset($_SESSION['prototyper_validation'][$action])) {
$_SESSION['prototyper_validation'][$action] = array();
}
$_SESSION['prototyper_validation'][$action][$shortname] = array(
'stat... | php | {
"resource": ""
} |
q250409 | EndpointParser.parseUrl | validation | public static function parseUrl($url): Endpoint
{
$url = UrlParser::parseUrl($url);
return new Endpoint($url->getAddress(), $url->getPort());
} | php | {
"resource": ""
} |
q250410 | Message.setTimestampCreated | validation | public function setTimestampCreated($postTime)
{
if ($postTime instanceof DateTime) {
$this->timestampCreated = $postTime;
} else {
$this->timestampCreated = new DateTime($postTime);
}
return $this;
} | php | {
"resource": ""
} |
q250411 | SettingController.updateCompany | validation | public function updateCompany(\Unite\Contacts\Http\Requests\UpdateRequest $request)
{
$this->service->saveCompanyProfile( $request->all() );
return $this->successJsonResponse();
} | php | {
"resource": ""
} |
q250412 | ConfigProvider.getControllerPluginConfig | validation | public function getControllerPluginConfig()
{
return [
'aliases' => [
'email' => Controller\Plugin\Email::class,
'mutex' => Controller\Plugin\Mutex::class,
'referer' => Controller\Plugin\Referer::class,
'settings' => Controller\Plug... | php | {
"resource": ""
} |
q250413 | ConfigProvider.getViewHelpers | validation | public function getViewHelpers()
{
return [
'aliases' => [
'formmulticheckbox' => Form\View\Helper\FormMultiCheckbox::class,
'formradio' => Form\View\Helper\FormRadio::class,
'zettaFlashMessenger' => View\Helper\FlashMessenger::class,
... | php | {
"resource": ""
} |
q250414 | JsonToMenuTreeTransformer.reverseTransform | validation | public function reverseTransform($jsonMenuNodes)
{
// TODO add exception
if ($jsonMenuNodes instanceof Collection && $jsonMenuNodes->count() === 0) {
return new ArrayCollection();
}
$this->allNodes = [];
// TODO handle no node
$firstNode = json_decode($js... | php | {
"resource": ""
} |
q250415 | JsonToMenuTreeTransformer.hierarchyToFlatArray | validation | private function hierarchyToFlatArray($items) {
$flatArray = [];
foreach($items as $item) {
$flatArray[] = $item->getId();
// TODO generalize
if($items->getChildren()->count() > 0) {
$flatArray = array_merge($flatArray, $this->hierarchyToFlatArray($ite... | php | {
"resource": ""
} |
q250416 | Referer.fromRoute | validation | public function fromRoute($route = null, $params = [], $options = [], $reuseMatchedParams = false)
{
$controller = $this->getController();
if (!$controller || !method_exists($controller, 'plugin')) {
throw new Exception\DomainException('Redirect plugin requires a controller that defines ... | php | {
"resource": ""
} |
q250417 | Configuration.getPlugins | validation | public function getPlugins()
{
// iterate over the operations and return the subjects of the actual one
/** @var TechDivision\Import\Configuration\OperationInterface $operation */
foreach ($this->getOperations() as $operation) {
if ($this->getOperation()->equals($operation)) {
... | php | {
"resource": ""
} |
q250418 | Configuration.mapBoolean | validation | public function mapBoolean($value)
{
// try to map the passed value to a boolean
if (isset($this->booleanMapping[$value])) {
return $this->booleanMapping[$value];
}
// throw an exception if we can't convert the passed value
throw new \Exception(sprintf('Can\'t c... | php | {
"resource": ""
} |
q250419 | Configuration.getDatabaseById | validation | public function getDatabaseById($id)
{
// iterate over the configured databases and return the one with the passed ID
/** @var TechDivision\Import\Configuration\DatabaseInterface $database */
foreach ($this->databases as $database) {
if ($database->getId() === $id) {
... | php | {
"resource": ""
} |
q250420 | Configuration.getDatabase | validation | public function getDatabase()
{
// if a DB ID has been set, try to load the database
if ($useDbId = $this->getUseDbId()) {
return $this->getDatabaseById($useDbId);
}
// iterate over the configured databases and try return the default database
/** @var TechDivisi... | php | {
"resource": ""
} |
q250421 | AbstractView.getViewSettings | validation | final public function getViewSettings()
{
$rf = new \ReflectionClass($this);
$this->viewName = str_replace('View', '', $rf->getShortName());
$matches = array();
if (preg_match("#@applyTo\((.*)\)#", $rf->getDocComment(), $matches)) {
$params = array();
... | php | {
"resource": ""
} |
q250422 | Memory.forget | validation | public function forget($args = [])
{
if (!empty($args)) {
if (is_array($args)) {
$args = implode('_', $args);
}
if (empty($this->forgetful)) {
$this->forgetful = get_class_methods($this);
}
foreach ($this->forgetful... | php | {
"resource": ""
} |
q250423 | Memory.remember | validation | public function remember($value, $memoryDuration = null)
{
if (is_null($memoryDuration)) {
$memoryDuration = $this->memoryDuration;
}
$key = $this->getRememberKey();
if (Cache::has($key)) {
$value = Cache::get($key);
} else {
$expiresAt =... | php | {
"resource": ""
} |
q250424 | Memory.forgetByKey | validation | protected function forgetByKey($key)
{
$result = false;
if (Cache::has($key)) {
$result = Cache::forget($key);
}
return $result;
} | php | {
"resource": ""
} |
q250425 | Memory.getRememberKey | validation | protected function getRememberKey()
{
$backtrace = debug_backtrace(4)[2];
$args = implode('_', $backtrace['args']);
$key = str_replace('\\', '_', get_class($this).'_'.$backtrace['function'].'_'.$args);
return $key;
} | php | {
"resource": ""
} |
q250426 | ConfigurationFactory.toArray | validation | protected function toArray($data, $type, $format)
{
// load the serializer builde
$serializer = SerializerBuilder::create()->build();
// deserialize the data, convert it into an array and return it
return $serializer->toArray($serializer->deserialize($data, $type, $format));
} | php | {
"resource": ""
} |
q250427 | ConfigurationFactory.mergeParams | validation | protected function mergeParams(&$data, $params)
{
// merge the passed params into the configuration data
foreach ($params as $paramName => $paramValue) {
if (is_array($paramValue)) {
foreach ($paramValue as $key => $value) {
foreach ($value as $name =... | php | {
"resource": ""
} |
q250428 | GoogleCampaignPlugin.embedCampaigns | validation | public static function embedCampaigns(
$html,
$campaign = [],
$additionalCampaigns = []
) {
$pattern = '/<a(\s[^>]*)href="([^"]*)"([^>]*)>/si';
$html = preg_replace_callback($pattern, function($matches) use ($campaign, $additionalCampaigns) {
$href = GoogleCampai... | php | {
"resource": ""
} |
q250429 | ClientSocket.connect | validation | public function connect()
{
if (!is_resource($this->handle)) {
throw new SocketException("Socket is not available");
}
if (! @socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) {
$code = socket_last_error($this->handle);
... | php | {
"resource": ""
} |
q250430 | Presentable.present | validation | public function present()
{
$presenterClass = $this->getPresenterClass();
if (!class_exists($presenterClass)) {
throw new Exceptions\PresenterException('The specified presenter does not exist.');
}
if (!$this->presenterInstance) {
$this->presenterInstance = ... | php | {
"resource": ""
} |
q250431 | FlashMessenger.render | validation | public function render(array $classes = [], $autoEscape = null)
{
$divOpen = '<div class="' . $this->divClass . '">';
$divClose = '</div>';
$hasMessages = false;
foreach ($this->classes as $namespace => $namespaceClasses) {
$namespaceClasses = ArrayUtils::merge($namespac... | php | {
"resource": ""
} |
q250432 | Converter.convert | validation | public static function convert($identifier, $sourceFormat, $outputFormat)
{
$parts = Parser::parse($identifier, $sourceFormat);
return Formatter::format($parts, $outputFormat);
} | php | {
"resource": ""
} |
q250433 | Manager.init | validation | public function init()
{
if ($this->isInitialized())
return true;
// attach default listeners
/** @var $sharedEvents \Zend\EventManager\SharedEventManager */
$sm = $this->getServiceManager();
$defaultListeners = $sm->get('yimaTheme.Manager.ListenerAggregate');
... | php | {
"resource": ""
} |
q250434 | Theme.init | validation | public function init()
{
if ($this->isInitialized())
return $this;
if (!$this->getThemesPath() || !$this->getName())
throw new \Exception('Theme Cant initialize because theme name or theme paths not present.');
$themePathname = $this->getThemesPath().DS.$this->getNa... | php | {
"resource": ""
} |
q250435 | Theme.addChild | validation | public function addChild(ModelInterface $child, $captureTo = null, $append = null)
{
parent::addChild($child, $captureTo, $append);
if ($child instanceof ThemeDefaultInterface) {
$child->parent = $this;
}
return $this;
} | php | {
"resource": ""
} |
q250436 | Theme.setThemesPath | validation | public function setThemesPath($path)
{
if (!is_dir($path)) {
throw new \Exception(
sprintf('Path "%s" not found.', $path)
);
}
$this->themesPath = rtrim($path, DS);
return $this;
} | php | {
"resource": ""
} |
q250437 | Theme.config | validation | public function config()
{
if (!$this->config) {
$config = array();
$configFile = $this->getThemesPath()
.DIRECTORY_SEPARATOR.$this->getName()
.DIRECTORY_SEPARATOR.'theme.config.php';
if (file_exists($configFile)) {
ob_star... | php | {
"resource": ""
} |
q250438 | DiscussController.getTag | validation | public function getTag()
{
if (null !== $this->tag) {
return $this->tag;
}
$categoryId = $this->getEvent()->getRouteMatch()->getParam('categoryid');
if (is_numeric($categoryId)) {
return $this->tag = $this->getDiscussService()->getCategoryById($categoryId);
... | php | {
"resource": ""
} |
q250439 | UserConnection.getRedirectUrlForAuth | validation | public function getRedirectUrlForAuth()
{
//Oauth1 plugin to get access tokens!
$oauth = new Oauth1(array(
'consumer_key' => $this->credentials->getConsumerKey(),
'consumer_secret' => $this->credentials->getConsumerSecret(),
'callback' => $this->credenti... | php | {
"resource": ""
} |
q250440 | UserConnection.getAccessToken | validation | public function getAccessToken($oauthToken, $oauthVerifier)
{
//Oauth1 plugin to get access tokens!
$oauth = new Oauth1(array(
'consumer_key' => $this->credentials->getConsumerKey(),
'consumer_secret' => $this->credentials->getConsumerSecret(),
'token' ... | php | {
"resource": ""
} |
q250441 | UserConnection.uploadMedia | validation | public function uploadMedia($filepaths, $client = null)
{
//maximum number of media files that a user can upload
$maxMediaIds = Config::get('max_media_ids');
//if number of media files supplied is larger than $maxMediaIds, throw exception.
if(count($filepaths) > $maxMediaIds)
... | php | {
"resource": ""
} |
q250442 | AppConnection.createBearerCredentials | validation | private function createBearerCredentials()
{
//URL encode the consumer key and consumer secret
$consumerKey = rawurlencode($this->credentials->getConsumerKey());
$consumerSecret = rawurlencode($this->credentials->getConsumerSecret());
//create bearer token credentials by concatenati... | php | {
"resource": ""
} |
q250443 | AppConnection.createBearerToken | validation | public function createBearerToken()
{
//get bearer token credentials - to be used for getting the bearer token from Twitter.
$bearerCredentials = $this->createBearerCredentials();
//Required Headers
$headers = array(
'Authorization' => 'Basic ' . $bearerCredentials,
... | php | {
"resource": ""
} |
q250444 | Connection.get | validation | public function get($endpoint, $params = null)
{
//prepend Twitter's API version to the endpoint
$endpoint = $this->prependVersionToEndpoint($endpoint, Config::get('api_version'));
//contruct an options array to configure the request
$options = $this->constructRequestOptions($params... | php | {
"resource": ""
} |
q250445 | Config.get | validation | public static function get($item)
{
//convert the item requested to upper, just in case.
$item = strtoupper($item);
//get all config items as an associative array from the JSON file
$config = json_decode(file_get_contents(dirname(__FILE__) . "/Config.json"), true);
//if the... | php | {
"resource": ""
} |
q250446 | BasicSeedShell.init | validation | public function init() {
$path = $this->absolutePath($this->getFile());
$this->quiet('Initializing seed file: ' . $this->shortPath($path));
$this->existsOrCreate($path);
} | php | {
"resource": ""
} |
q250447 | BasicSeedShell.importTables | validation | public function importTables(array $data) {
$tableCount = count($data);
$this->out("<info>Starting seed of {$tableCount} table(s).</info>");
foreach ($data as $table => $records) {
$this->out("<info>{$table}</info>");
// Set default field values.
$defaults = [];
if (array_key_exists('_defaults', $re... | php | {
"resource": ""
} |
q250448 | BasicSeedShell.importTable | validation | public function importTable(Table $Table, $records, array $options = []) {
$defaultOptions = [
'checkRules' => true,
'checkExisting' => true,
];
$options = $options + $defaultOptions;
foreach ($records as $record) {
$action = ($record->isNew() ? 'Create' : 'Update');
$result = $Table->save($record,... | php | {
"resource": ""
} |
q250449 | BasicSeedShell.truncateTable | validation | protected function truncateTable($Table) {
$truncateSql = $Table->schema()->truncateSql($Table->connection())[0];
$success = $Table->connection()->query($truncateSql);
if ($success) {
$this->verbose("<success>{$Table->alias()}: Existing DB records truncated.</success>");
} else {
$this->quiet("<warning>{$... | php | {
"resource": ""
} |
q250450 | BasicSeedShell.findKey | validation | protected function findKey(Table $Table, Entity $entity) {
if (!empty($entity->{$Table->primaryKey()})) {
$key = $entity->{$Table->primaryKey()};
} else {
$key = 'unknown';
}
return $key;
} | php | {
"resource": ""
} |
q250451 | BasicSeedShell.printValidationErrors | validation | protected function printValidationErrors($table, $id, $errors) {
foreach ($errors as $field => $messages) {
foreach ((array)$messages as $message) {
$this->quiet("<warning>{$table} ({$id}): {$field}: {$message}</warning>");
}
}
} | php | {
"resource": ""
} |
q250452 | BasicSeedShell.getFile | validation | protected function getFile() {
$file = ($this->params['dev'] ? $this->seedDevFile : $this->seedFile);
if (!empty($this->params['file'])) {
$file = $this->params['file'];
}
return $file;
} | php | {
"resource": ""
} |
q250453 | BasicSeedShell.existsOrCreate | validation | protected function existsOrCreate($file) {
if (!file_exists($file)) {
$this->out('<info>Creating empty seed file: ' . $this->shortPath($file) . '</info>');
file_put_contents($file, <<<'EOD'
<?php
/**
* BasicSeed plugin data seed file.
*/
namespace App\Config\BasicSeed;
use Cake\ORM\TableRegistry;
// Write... | php | {
"resource": ""
} |
q250454 | BasicSeedShell.getOptionParser | validation | public function getOptionParser() {
$parser = parent::getOptionParser();
$parser
->description(
'Provides a mechanism for loading data into any of Cake\'s configured databases.'
)
->addSubcommand('init', [
'help' => 'Initialize a new, empty seed file. Respects both the --dev and --file options.',
... | php | {
"resource": ""
} |
q250455 | PageController.actionCreate | validation | public function actionCreate()
{
$model = new StaticPage();
$model->time = date("Y-m-d H:i:s");
$model->isdel = 0;
$post = Yii::$app->request->post();
if (isset($post['StaticPage']['tags']))
{
if (is_array($post['StaticPage']['tags']))
{
$post['StaticPage']['t... | php | {
"resource": ""
} |
q250456 | PageController.actionUpdate | validation | public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->tags = !empty($model->tags)?explode(",",$model->tags):[];
$post = Yii::$app->request->post();
if (isset($post['StaticPage']['tags']))
{
if (is_array($post['StaticPage']['tags']))
{
$post['StaticPage']['tags'] = ... | php | {
"resource": ""
} |
q250457 | PageController.actionDelete | validation | public function actionDelete($id)
{
$model = $this->findModel($id);
$model->isdel = 1;
$model->save();
//$model->delete(); //this will true delete
return $this->redirect(['index']);
} | php | {
"resource": ""
} |
q250458 | CanvasArray.parsePageLinks | validation | protected function parsePageLinks($headers = false)
{
$pagination = [];
if (!$headers) {
$headers = $this->api->lastHeader('link');
}
/* parse Canvas page links */
if (preg_match_all('%<([^>]*)>\s*;\s*rel="([^"]+)"%', $headers, $links, PREG_SET_ORDER)) {
... | php | {
"resource": ""
} |
q250459 | CanvasArray.pageNumberToKey | validation | protected function pageNumberToKey($pageNumber)
{
if (isset($this->pagination[CanvasPageLink::CURRENT])) {
return ($pageNumber - 1) * $this->pagination[CanvasPageLink::CURRENT]->getPerPage();
}
return false;
} | php | {
"resource": ""
} |
q250460 | CanvasArray.requestPageNumber | validation | protected function requestPageNumber($pageNumber, $forceRefresh = false)
{
if (!isset($this->data[$this->pageNumberToKey($pageNumber)]) || ($forceRefresh && isset($this->api))) {
// assume one page if no pagination (and already loaded)
if (isset($this->pagination[CanvasPageLink::CURR... | php | {
"resource": ""
} |
q250461 | CanvasArray.requestAllPages | validation | protected function requestAllPages($forceRefresh = false)
{
$_page = $this->page;
$_key = $this->key;
$nextPageNumber = false;
if (isset($this->pagination[CanvasPageLink::NEXT])) {
$nextPageNumber = $this->pagination[CanvasPageLink::NEXT]->getPageNumber();
}
... | php | {
"resource": ""
} |
q250462 | CanvasArray.offsetExists | validation | public function offsetExists($offset)
{
if (!isset($this->data[$offset])) {
$this->requestAllPages();
}
return isset($this->data[$offset]);
} | php | {
"resource": ""
} |
q250463 | CanvasArray.serialize | validation | public function serialize()
{
$this->requestAllPages();
return serialize(
array(
'page' => $this->page,
'key' => $this->key,
'data' => $this->data
)
);
} | php | {
"resource": ""
} |
q250464 | CanvasArray.unserialize | validation | public function unserialize($data)
{
$_data = unserialize($data);
$this->page = $_data['page'];
$this->key = $_data['key'];
$this->data = $_data['data'];
$this->api = null;
$this->endpoint = null;
$this->pagination = array();
} | php | {
"resource": ""
} |
q250465 | CanvasPest.setupToken | validation | public function setupToken($token)
{
if (!empty($token)) {
$this->headers['Authorization'] = "Bearer $token";
return true;
} else {
if ($this->throw_exceptions) {
throw new CanvasPest_Exception(
'API authorization token must be ... | php | {
"resource": ""
} |
q250466 | CanvasPest.preprocessData | validation | private function preprocessData($data)
{
if (is_array($data) && !array_key_exists(self::PARAM_PER_PAGE, $data)) {
$data[self::PARAM_PER_PAGE] = CanvasArray::MAXIMUM_PER_PAGE;
}
return $data;
} | php | {
"resource": ""
} |
q250467 | CanvasPest.get | validation | public function get($path, $data = array(), $headers = array())
{
return $this->postprocessResponse(
parent::get($path, $this->preprocessData($data), $headers)
);
} | php | {
"resource": ""
} |
q250468 | CanvasPest.post | validation | public function post($path, $data = array(), $headers = array())
{
return $this->postprocessResponse(
parent::post($path, $this->preprocessData($data), $headers)
);
} | php | {
"resource": ""
} |
q250469 | CanvasPest.put | validation | public function put($path, $data = array(), $headers = array())
{
return $this->postprocessResponse(
parent::put($path, $this->preprocessData($data), $headers)
);
} | php | {
"resource": ""
} |
q250470 | CanvasPest.delete | validation | public function delete($path, $data = array(), $headers = array())
{
if (!empty($data)) {
$pathData = [];
$pos = strpos($path, '?');
if ($pos !== false) {
parse_str(substr($path, $pos + 1), $pathData);
$path = substr($path, 0, $pos);
... | php | {
"resource": ""
} |
q250471 | CanvasPest.patch | validation | public function patch($path, $data = array(), $headers = array())
{
if ($this->throw_exceptions) {
throw new CanvasPest_Exception(
'The Canvas API does not support the PATCH method',
CanvasPest_Exception::UNSUPPORTED_METHOD
);
}
return ... | php | {
"resource": ""
} |
q250472 | PostController.actionIndex | validation | public function actionIndex($format= false,$arraymap= false,$term = false,$category = false,$time = false)
{
$searchModel = new PostSearch();
$req = Yii::$app->request->queryParams;
if ($term) { $req[basename(str_replace("\\","/",get_class($searchModel)))]["term"] = $... | php | {
"resource": ""
} |
q250473 | PostController.actionView | validation | public function actionView($id,$format= false)
{
$model = $this->findModel($id);
if ($format == 'json')
{
return \yii\helpers\Json::encode($model);
}
else
{
return $this->render('view', [
'model' => $model,
]);
}
} | php | {
"resource": ""
} |
q250474 | PostController.actionCreate | validation | public function actionCreate()
{
$model = new Post();
$model->time = date("Y-m-d H:i:s");
$model->author_id = Yii::$app->user->id;
$model->isdel = 0;
if (Yii::$app->request->post())
{
$post = Yii::$app->request->post();
$category = [];
... | php | {
"resource": ""
} |
q250475 | PostController.actionUpdate | validation | public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->tags = !empty($model->tags)?explode(",",$model->tags):[];
if (Yii::$app->request->post())
{
$post = Yii::$app->request->post();
$category = [];
if (isset($post['Post']['category']))
... | php | {
"resource": ""
} |
q250476 | BannerController.actionCreate | validation | public function actionCreate()
{
$model = new Banner();
$model->time = date("Y-m-d H:i:s");
$model->position = $model->getLast();
$model->isdel = 0;
$post = Yii::$app->request->post();
if (isset($post['Banner']['tags']))
{
if (is_array($post['Banner']['tags']))
{
$... | php | {
"resource": ""
} |
q250477 | BannerController.actionUpdate | validation | public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->tags = !empty($model->tags)?explode(",",$model->tags):[];
$post = Yii::$app->request->post();
if (isset($post['Banner']['tags']))
{
if (is_array($post['Banner']['tags']))
{
$post['Banner']['tags'] = imp... | php | {
"resource": ""
} |
q250478 | SchemaAnalyzer.getAmbiguityExceptionMessage | validation | private function getAmbiguityExceptionMessage(array $paths, Vertex $startVertex, Vertex $endVertex)
{
$textPaths = [];
$i = 1;
foreach ($paths as $path) {
$textPaths[] = 'Path '.$i.': '.$this->getTextualPath($path, $startVertex);
++$i;
}
$msg = sprint... | php | {
"resource": ""
} |
q250479 | SchemaAnalyzer.getTextualPath | validation | private function getTextualPath(array $path, Vertex $startVertex)
{
$currentVertex = $startVertex;
$currentTable = $currentVertex->getId();
$textPath = $currentTable;
foreach ($path as $edge) {
/* @var $fk ForeignKeyConstraint */
if ($fk = $edge->getAttribut... | php | {
"resource": ""
} |
q250480 | SchemaAnalyzer.isInheritanceRelationship | validation | private function isInheritanceRelationship(ForeignKeyConstraint $fk)
{
if (!$fk->getLocalTable()->hasPrimaryKey()) {
return false;
}
$fkColumnNames = $fk->getLocalColumns();
$pkColumnNames = $fk->getLocalTable()->getPrimaryKeyColumns();
sort($fkColumnNames);
... | php | {
"resource": ""
} |
q250481 | LanguageSwitcherHelper.renderLanguageSwitcher | validation | public function renderLanguageSwitcher()
{
return $this->_View->element($this->config('element'), [
'availableLanguages' => $this->config('availableLanguages'),
'displayNames' => $this->config('displayNames'),
'imageMapping' => $this->config('imageMapping'),
'... | php | {
"resource": ""
} |
q250482 | LanguageSwitcherHelper.getUrl | validation | public function getUrl($language)
{
$lang = ['lang' => $language];
$query = Hash::merge($this->request->query, $lang);
$urlArray = Hash::merge($this->request->params['pass'], ['?' => $query]);
return Router::url($urlArray);
} | php | {
"resource": ""
} |
q250483 | LanguageSwitcherMiddleware.__next | validation | private function __next(ServerRequestInterface $request, ResponseInterface $response, $next)
{
$this->__loadConfigFiles();
return $next($request, $response);
} | php | {
"resource": ""
} |
q250484 | LanguageSwitcherMiddleware.__setCookieAndLocale | validation | private function __setCookieAndLocale($locale)
{
// @FIXME Should be refactored when cake 3.4 was released
if (PHP_SAPI !== 'cli') {
$time = $this->__getCookieExpireTime();
I18n::locale($locale);
setcookie($this->__getCookieName(), $locale, $time, '/', $this->conf... | php | {
"resource": ""
} |
q250485 | LanguageSwitcherMiddleware.__loadConfigFiles | validation | private function __loadConfigFiles()
{
$additionalConfigs = $this->config('additionalConfigFiles');
foreach ($additionalConfigs as $additionalConfig) {
Configure::load($additionalConfig);
}
} | php | {
"resource": ""
} |
q250486 | GroupCountBasedDataGenerator.parseDynamicGroup | validation | private function parseDynamicGroup($group)
{
$regex = $group['regex'];
$parts = explode('|', $regex);
$data = array();
foreach ($group['routeMap'] as $matchIndex => $routeData) {
if (!is_array($routeData[0]) || !isset($routeData[0]['name']) || !isset($parts[$matchIndex - ... | php | {
"resource": ""
} |
q250487 | GroupCountBasedDataGenerator.replaceOnce | validation | private function replaceOnce($search, $replace, $subject)
{
$pos = strpos($subject, $search);
if ($pos !== false) {
$subject = substr_replace($subject, $replace, $pos, strlen($search));
}
return $subject;
} | php | {
"resource": ""
} |
q250488 | ClassName.from | validation | public function from(Contract $contract, string $string, callable $callback = null): string
{
$string = ucwords(
$contract->recipe(
$string,
'upperCaseFirst',
function ($string) use ($contract) {
if ($contract instanceof Camel)... | php | {
"resource": ""
} |
q250489 | Camel.from | validation | public function from(Contract $contract, string $string, callable $callback = null): string
{
return $this->callback(
$contract->recipe(
$string,
'upperCaseFirst',
function ($string) use ($contract) {
if ($contract instanceof C... | php | {
"resource": ""
} |
q250490 | SimpleUrlGenerator.generate | validation | public function generate($name, array $parameters = array(), $absolute = false)
{
if (!$this->initialized) {
$this->initialize();
}
$path = $this->routes[$name];
if (is_array($path)) {
$params = $path['params'];
$path = $path['path'];
... | php | {
"resource": ""
} |
q250491 | Application.boot | validation | public function boot()
{
if ($this->booted) {
return;
}
$this->container = $this->initializeContainer();
$this->kernel = $this->container->get('http_kernel');
$this->booted = true;
} | php | {
"resource": ""
} |
q250492 | Application.addCompilerPass | validation | public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION)
{
$this->compilerPasses[] = array($pass, $type);
} | php | {
"resource": ""
} |
q250493 | Application.initializeContainer | validation | protected function initializeContainer()
{
$this->registerDefaultExtensions();
$initializer = $this->getContainerInitializer();
$this->container = $initializer->initializeContainer($this, $this->extensions, $this->compilerPasses);
$this->container->set('app', $this);
return ... | php | {
"resource": ""
} |
q250494 | Application.getContainerInitializer | validation | protected function getContainerInitializer()
{
$initializer = new DefaultInitializer($this->getConfigurationProvider());
if ($this->cache) {
$initializer = new CachedInitializer($initializer, $this->getCacheDir());
}
return $initializer;
} | php | {
"resource": ""
} |
q250495 | Application.handle | validation | public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
{
if (!$this->booted) {
$this->boot();
}
$request->attributes->set('app', $this);
return $this->kernel->handle($request, $type, $catch);
} | php | {
"resource": ""
} |
q250496 | Application.getRootDir | validation | public function getRootDir()
{
if (!$this->rootDir) {
$refl = new \ReflectionObject($this);
$filename = $refl->getFileName();
if (false !== ($pos = strrpos($filename, '/vendor/'))) {
$filename = substr($filename, 0, $pos);
} else {
... | php | {
"resource": ""
} |
q250497 | Application.set | validation | public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER)
{
if (!$this->booted) {
$this->boot();
}
$this->container->set($id, $service, $scope);
} | php | {
"resource": ""
} |
q250498 | Application.get | validation | public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
{
if (!$this->booted) {
$this->boot();
}
return $this->container->get($id, $invalidBehavior);
} | php | {
"resource": ""
} |
q250499 | CachedInitializer.dumpContainer | validation | protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
{
$dumper = new PhpDumper($container);
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass));
$cache->write($content, $container->getResources());
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.