_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q249300 | WorkerPool.setSemaphore | validation | public function setSemaphore(Semaphore $semaphore) {
if ($this->created) {
throw new WorkerPoolException('Cannot set the Worker Pool Size for a created pool.');
}
if (!$semaphore->isCreated()) {
throw new \InvalidArgumentException('The Semaphore hasn\'t yet been created.');
}
$this->semaphore = $semapho... | php | {
"resource": ""
} |
q249301 | WorkerPool.createWorker | validation | private function createWorker($i) {
$sockets = array();
if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $sockets) === FALSE) {
// clean_up using posix_kill & pcntl_wait
throw new \RuntimeException('socket_create_pair failed.');
return;
}
$processId = pcntl_fork();
if ($processId < 0) {
// cleanup ... | php | {
"resource": ""
} |
q249302 | WorkerPool.runWorkerProcess | validation | protected function runWorkerProcess(WorkerInterface $worker, SimpleSocket $simpleSocket, $i) {
$replacements = array(
'basename' => basename($_SERVER['PHP_SELF']),
'fullname' => $_SERVER['PHP_SELF'],
'class' => get_class($worker),
'i' => $i,
'state' => 'free'
);
ProcessDetails::setProcessTitle($thi... | php | {
"resource": ""
} |
q249303 | WorkerPool.destroy | validation | public function destroy($maxWaitSecs = null) {
if ($maxWaitSecs === null) {
$maxWaitSecs = $this->child_timeout_sec;
}
if (!$this->created) {
throw new WorkerPoolException('The pool hasn\'t yet been created.');
}
$this->created = FALSE;
if ($this->parentPid === getmypid()) {
$maxWaitSecs = ((int)$... | php | {
"resource": ""
} |
q249304 | WorkerPool.reaper | validation | protected function reaper($pid = -1) {
if (!is_int($pid)) {
$pid = -1;
}
$childpid = pcntl_waitpid($pid, $status, WNOHANG);
while ($childpid > 0) {
$stopSignal = pcntl_wstopsig($status);
if (pcntl_wifexited($stopSignal) === FALSE) {
array_push($this->results, array(
'pid' => $childpid,
'a... | php | {
"resource": ""
} |
q249305 | WorkerPool.getFreeAndBusyWorkers | validation | public function getFreeAndBusyWorkers() {
$free = $this->getFreeWorkers();
return array(
'free' => $free,
'busy' => $this->workerPoolSize - $free,
'total' => $this->workerPoolSize
);
} | php | {
"resource": ""
} |
q249306 | WorkerPool.getNextFreeWorker | validation | protected function getNextFreeWorker() {
$sec = 0;
while (TRUE) {
$this->collectWorkerResults($sec);
$freeProcess = $this->workerProcesses->takeFreeProcess();
if ($freeProcess !== NULL) {
return $freeProcess;
}
$sec = $this->child_timeout_sec;
if ($this->workerPoolSize <= 0) {
throw new ... | php | {
"resource": ""
} |
q249307 | WorkerPool.collectWorkerResults | validation | protected function collectWorkerResults($sec = 0) {
$this->respawnIfRequired();
// dispatch signals
pcntl_signal_dispatch();
if (isset($this->workerProcesses) === FALSE) {
throw new WorkerPoolException('There is no list of worker processes. Maybe you destroyed the worker pool?', 1401179881);
}
$result ... | php | {
"resource": ""
} |
q249308 | WorkerPool.run | validation | public function run($input) {
while ($this->workerPoolSize > 0) {
try {
$processDetailsOfFreeWorker = $this->getNextFreeWorker();
$processDetailsOfFreeWorker->getSocket()->send(array('cmd' => 'run', 'data' => $input));
return $processDetailsOfFreeWorker->getPid();
} catch (\Exception $e) {
pcntl... | php | {
"resource": ""
} |
q249309 | LdapConnection.connect | validation | public function connect()
{
$port = $this->ssl ? $this::PORT_SSL : $this::PORT;
$hostname = $this->domainController->getHostname();
return $this->connection = ldap_connect($hostname, $port);
} | php | {
"resource": ""
} |
q249310 | LdapConnection.bind | validation | public function bind($username, $password)
{
// Tries to run the LDAP Connection as TLS
if ($this->tls) {
if ( ! ldap_start_tls($this->connection)) {
throw new ConnectionException('Unable to Connect to LDAP using TLS.');
}
}
try {
... | php | {
"resource": ""
} |
q249311 | LdapConnection.getDomainControllerStrategy | validation | private function getDomainControllerStrategy(array $domain_controller)
{
$protocol = $this->ssl ? $this::PROTOCOL_SSL : $this::PROTOCOL;
if (count($domain_controller) === 1) {
return new SingleDomainController($protocol, $domain_controller);
}
if ($this->backup === true... | php | {
"resource": ""
} |
q249312 | LdapAuthUserProvider.retrieveByCredentials | validation | public function retrieveByCredentials(array $credentials)
{
$username = $credentials['username'];
$result = $this->ldap->find($username);
if( !is_null($result) ){
$user = new $this->model;
$user->build( $result );
return $user;
}
return ... | php | {
"resource": ""
} |
q249313 | LdapAuthUserProvider.validateCredentials | validation | public function validateCredentials(Authenticatable $user, array $credentials)
{
return $this->ldap->auth(
$user->dn,
$credentials['password']
);
} | php | {
"resource": ""
} |
q249314 | GuzzleClient.post | validation | public function post($endpoint, $data, $headers = [])
{
$request = new Request('POST', $endpoint, $headers, $data);
$response = $this->guzzle->send($request);
return $this->handle($response);
} | php | {
"resource": ""
} |
q249315 | GuzzleClient.delete | validation | public function delete($endpoint, $headers = [])
{
$request = new Request('DELETE', $endpoint, $headers);
$response = $this->guzzle->send($request);
return $this->handle($response);
} | php | {
"resource": ""
} |
q249316 | GuzzleClient.handle | validation | private function handle(Response $response)
{
$stream = stream_for($response->getBody());
$data = json_decode($stream->getContents());
return $data;
} | php | {
"resource": ""
} |
q249317 | Firebase.post | validation | public function post($endpoint, $data, $query = [])
{
$endpoint = $this->buildUri($endpoint, $query);
$headers = $this->buildHeaders();
$data = $this->prepareData($data);
$this->response = $this->client->post($endpoint, $data, $headers);
return $this->response;
} | php | {
"resource": ""
} |
q249318 | Firebase.delete | validation | public function delete($endpoint, $query = [])
{
$endpoint = $this->buildUri($endpoint, $query);
$headers = $this->buildHeaders();
$this->response = $this->client->delete($endpoint, $headers);
return $this->response;
} | php | {
"resource": ""
} |
q249319 | Firebase.buildUri | validation | protected function buildUri($endpoint, $options = [])
{
if ($this->token !== '') {
$options['auth'] = $this->token;
}
return $this->base.'/'.ltrim($endpoint, '/').'.json?'.http_build_query($options, '', '&');
} | php | {
"resource": ""
} |
q249320 | Log.& | validation | public function &getErrors($channel = null)
{
// Uses the passed channel or fallback to the current selected channel
$channel = $this->namespaceChannel($channel);
if ( ! isset($this->console['errors'][$channel]) ) {
$this->console['errors'][$channel] = array();
}
... | php | {
"resource": ""
} |
q249321 | Log.& | validation | public function &getReports($channel = null)
{
// Uses the passed channel or fallback to the current selected channel
$channel = $this->namespaceChannel($channel);
if (!isset($this->console['reports'][$channel])) {
// Create a new empty array to return as reference
$... | php | {
"resource": ""
} |
q249322 | Log.error | validation | public function error($message)
{
if ($message) {
if (is_int($message) && isset($this->errorList[$message])) {
/*
* If the message is of type integer use a predefine
* error message
*/
$errorMessage = $this->error... | php | {
"resource": ""
} |
q249323 | Log.report | validation | public function report($message)
{
$channel = $this->currentChannel;
if ($message) {
// Log the report to the console
$reports = &$this->getReports($channel);
$reports[] = $message;
}
return $this;
} | php | {
"resource": ""
} |
q249324 | Log.& | validation | public function &getFormErrors($channel = '')
{
// Uses the passed channel or fallback to the current selected channel
$channel = $this->namespaceChannel($channel);
if (!isset($this->console['form'][$channel])) {
$this->console['form'][$channel] = array();
}
ret... | php | {
"resource": ""
} |
q249325 | Log.clearErrors | validation | public function clearErrors($channelName='')
{
$channel = $this->namespaceChannel($channelName);
// Clear any existing errors for the channel
$this->console['errors'][$channel] = array();
$this->console['form'][$channel] = array();
} | php | {
"resource": ""
} |
q249326 | Log.addPredefinedError | validation | public function addPredefinedError($id, $message = '')
{
if (is_array($id)) {
$this->errorList = array_diff_key($this->errorList, $id) + $id;
} else {
$this->errorList[$id] = $message;
}
} | php | {
"resource": ""
} |
q249327 | Log.cleanConsole | validation | private function cleanConsole()
{
$channel = $this->namespaceChannel($this->currentChannel);
if (empty($this->console['errors'][$channel])) {
unset($this->console['errors'][$channel]);
}
if (empty($this->console['form'][$channel])) {
unset($this->console['fo... | php | {
"resource": ""
} |
q249328 | DB.getConnection | validation | public function getConnection()
{
if (!($this->log instanceof Log)) {
$this->log = new Log('DB');
}
// Use cached connection if already connected to server
if ($this->connection instanceof \PDO) {
return $this->connection;
}
$this->log->repor... | php | {
"resource": ""
} |
q249329 | Hash.generateUserPassword | validation | public function generateUserPassword(User $user, $password, $generateOld = false)
{
$registrationDate = $user->RegDate;
$pre = $this->encode($registrationDate);
$pos = substr($registrationDate, 5, 1);
$post = $this->encode($registrationDate * (substr($registrationDate, $pos, 1)));
... | php | {
"resource": ""
} |
q249330 | Hash.encode | validation | static protected function encode($number)
{
$k = self::$encoder;
preg_match_all("/[1-9][0-9]|[0-9]/", $number, $a);
$n = '';
$o = count($k);
foreach ($a[0] as $i) {
if ($i < $o) {
$n .= $k[$i];
} else {
$n .= '1' . $k[$i... | php | {
"resource": ""
} |
q249331 | Hash.generate | validation | static public function generate($uid = 0, $hash = false)
{
if ($uid) {
$e_uid = self::encode($uid);
$e_uid_length = strlen($e_uid);
$e_uid_length = str_pad($e_uid_length, 2, 0, STR_PAD_LEFT);
$e_uid_pos = rand(10, 32 - $e_uid_length - 1);
if (!$ha... | php | {
"resource": ""
} |
q249332 | Hash.examine | validation | static public function examine($hash)
{
if (strlen($hash) == 40 && preg_match("/^[0-9]{4}/", $hash)) {
$e_uid_pos = substr($hash, 0, 2);
$e_uid_length = substr($hash, 2, 2);
$e_uid = substr($hash, $e_uid_pos, $e_uid_length);
$uid = self::decode($e_uid);
... | php | {
"resource": ""
} |
q249333 | Hash.decode | validation | static public function decode($number)
{
$k = self::$encoder;
preg_match_all('/[1][a-zA-Z]|[2-9]|[a-zA-Z]|[0]/', $number, $a);
$n = '';
$o = count($k);
foreach ($a[0] as $i) {
$f = preg_match('/1([a-zA-Z])/', $i, $v);
if ($f == true) {
... | php | {
"resource": ""
} |
q249334 | Collection.get | validation | public function get($keyPath)
{
$stops = explode('.', $keyPath);
$value = $this;
foreach ($stops as $key) {
if ($value instanceof Collection) {
// Move one step deeper into the collection
$value = $value->$key;
} else {
... | php | {
"resource": ""
} |
q249335 | Collection.set | validation | public function set($keyPath, $value)
{
$stops = explode('.', $keyPath);
$currentLocation = $previousLocation = $this;
foreach ($stops as $key) {
if ($currentLocation instanceof Collection) {
// Move one step deeper into the collection
if (!($curr... | php | {
"resource": ""
} |
q249336 | Cookie.add | validation | public function add()
{
if (!headers_sent()) {
// Set the cookie via PHP headers
$added = setcookie(
$this->name,
$this->value,
round(time() + 60 * 60 * 24 * $this->lifetime),
$this->path,
$this->host
... | php | {
"resource": ""
} |
q249337 | Cookie.destroy | validation | public function destroy()
{
if (!is_null($this->getValue())) {
if (!headers_sent()) {
return setcookie(
$this->name,
'',
time() - 3600,
$this->path,
$this->host
); ... | php | {
"resource": ""
} |
q249338 | Session.validate | validation | private function validate()
{
/*
* Get the correct IP
*/
$server = new Collection($_SERVER);
$ip = $server->HTTP_X_FORWARDED_FOR;
if (is_null($ip) && $server->REMOTE_ADDR)
{
$ip = $server->REMOTE_ADDR;
}
if (!is_null($this->_ip)... | php | {
"resource": ""
} |
q249339 | UserBase.toCollection | validation | protected function toCollection($data)
{
if (is_array($data)) {
return new Collection($data);
} else {
if (!($data instanceof Collection)) {
// Invalid input type, return empty collection
$data = new Collection();
}
}
... | php | {
"resource": ""
} |
q249340 | UserBase.validateAll | validation | protected function validateAll($includeAllRules = false)
{
if ($includeAllRules) {
/*
* Include fields that might not have been included
*/
$fieldData = new Collection(array_fill_keys(array_keys($this->_validations->toArray()), null));
$fieldData... | php | {
"resource": ""
} |
q249341 | UserBase.validate | validation | protected function validate($name, $limit, $regEx = false)
{
$Name = ucfirst($name);
$value = $this->_updates->$name;
$length = explode('-', $limit);
$min = intval($length[0]);
$max = intval($length[1]);
if (!$max and !$min) {
$this->log->error("Invalid s... | php | {
"resource": ""
} |
q249342 | DB_Table.getRow | validation | public function getRow($arguments)
{
$sql = 'SELECT * FROM _table_ WHERE _arguments_ LIMIT 1';
if (!$stmt = $this->getStatement($sql, $arguments)) {
// Something went wrong executing the SQL statement
return false;
} else {
return $stmt->fetch();
... | php | {
"resource": ""
} |
q249343 | DB_Table.getStatement | validation | public function getStatement($sql, $args = false)
{
// The parsed sql statement
$query = $this->buildQuery($sql, $args);
if ($connection = $this->db->getConnection()) {
//Prepare the statement
if ($stmt = $connection->prepare($query)) {
//Log the SQL ... | php | {
"resource": ""
} |
q249344 | DB_Table.buildQuery | validation | private function buildQuery($sql, $arguments = null)
{
if (is_array($arguments)) {
$finalArgs = array();
foreach ($arguments as $field => $val) {
// Parametrize the arguments
$finalArgs[] = " {$field}=:{$field}";
}
// Join all ... | php | {
"resource": ""
} |
q249345 | DB_Table.query | validation | public function query($sql, $arguments = false)
{
if (!$stmt = $this->getStatement($sql, $arguments)) {
// Something went wrong executing the SQL statement
return false;
} else {
return $stmt;
}
} | php | {
"resource": ""
} |
q249346 | DB_Table.runQuery | validation | public function runQuery($sql, $arguments = false)
{
if (!$stmt = $this->getStatement($sql, $arguments)) {
// Something went wrong executing the SQL statement
return false;
}
// If there are no arguments, execute the statement
if (!$arguments) {
$... | php | {
"resource": ""
} |
q249347 | ContentReviewEmails.getEmailBody | validation | protected function getEmailBody($config, $variables)
{
$template = SSViewer::fromString($config->ReviewBody);
$value = $template->process(ArrayData::create($variables));
// Cast to HTML
return DBField::create_field('HTMLText', (string) $value);
} | php | {
"resource": ""
} |
q249348 | ContentReviewEmails.getTemplateVariables | validation | protected function getTemplateVariables($recipient, $config, $pages)
{
return [
'Subject' => $config->ReviewSubject,
'PagesCount' => $pages->count(),
'FromEmail' => $config->ReviewFrom,
'ToFirstName' => $recipient->FirstName,
'ToSurname' => $recipi... | php | {
"resource": ""
} |
q249349 | ContentReviewDefaultSettings.getReviewFrom | validation | public function getReviewFrom()
{
$from = $this->owner->getField('ReviewFrom');
if ($from) {
return $from;
}
// Fall back to admin email
return Config::inst()->get(Email::class, 'admin_email');
} | php | {
"resource": ""
} |
q249350 | ContentReviewDefaultSettings.getWithDefault | validation | protected function getWithDefault($field)
{
$value = $this->owner->getField($field);
if ($value) {
return $value;
}
// fallback to default value
$defaults = $this->owner->config()->get('defaults');
if (isset($defaults[$field])) {
return $defaul... | php | {
"resource": ""
} |
q249351 | ContentReviewCompatability.start | validation | public static function start()
{
$compatibility = [
self::SUBSITES => null,
];
if (ClassInfo::exists(Subsite::class)) {
$compatibility[self::SUBSITES] = Subsite::$disable_subsite_filter;
Subsite::disable_subsite_filter(true);
}
return $co... | php | {
"resource": ""
} |
q249352 | ContentReviewNotificationJob.queueNextRun | validation | protected function queueNextRun()
{
$nextRun = new ContentReviewNotificationJob();
$nextRunTime = mktime(
Config::inst()->get(__CLASS__, 'next_run_hour'),
Config::inst()->get(__CLASS__, 'next_run_minute'),
0,
date("m"),
date("d") + Config:... | php | {
"resource": ""
} |
q249353 | SiteTreeContentReview.merge_owners | validation | public static function merge_owners(SS_List $groups, SS_List $members)
{
$contentReviewOwners = new ArrayList();
if ($groups->count()) {
$groupIDs = [];
foreach ($groups as $group) {
$familyIDs = $group->collateFamilyIDs();
if (is_array($fam... | php | {
"resource": ""
} |
q249354 | SiteTreeContentReview.getReviewDate | validation | public function getReviewDate(SiteTree $page = null)
{
if ($page === null) {
$page = $this->owner;
}
if ($page->obj('NextReviewDate')->exists()) {
return $page->obj('NextReviewDate');
}
$options = $this->owner->getOptions();
if (!$options) {... | php | {
"resource": ""
} |
q249355 | SiteTreeContentReview.addReviewNote | validation | public function addReviewNote(Member $reviewer, $message)
{
$reviewLog = ContentReviewLog::create();
$reviewLog->Note = $message;
$reviewLog->ReviewerID = $reviewer->ID;
$this->owner->ReviewLogs()->add($reviewLog);
} | php | {
"resource": ""
} |
q249356 | SiteTreeContentReview.advanceReviewDate | validation | public function advanceReviewDate()
{
$nextDateTimestamp = false;
$options = $this->getOptions();
if ($options && $options->ReviewPeriodDays) {
$nextDateTimestamp = strtotime(
' + ' . $options->ReviewPeriodDays . ' days',
DBDatetime::now()->getTim... | php | {
"resource": ""
} |
q249357 | SiteTreeContentReview.canBeReviewedBy | validation | public function canBeReviewedBy(Member $member = null)
{
if (!$this->owner->obj("NextReviewDate")->exists()) {
return false;
}
if ($this->owner->obj("NextReviewDate")->InFuture()) {
return false;
}
$options = $this->getOptions();
if (!$optio... | php | {
"resource": ""
} |
q249358 | SiteTreeContentReview.onBeforeWrite | validation | public function onBeforeWrite()
{
// Only update if DB fields have been changed
$changedFields = $this->owner->getChangedFields(true, 2);
if ($changedFields) {
$this->owner->LastEditedByName = $this->owner->getEditorName();
$this->owner->OwnerNames = $this->owner->get... | php | {
"resource": ""
} |
q249359 | ReviewContentHandler.Form | validation | public function Form($object)
{
$placeholder = _t(__CLASS__ . '.Placeholder', 'Add comments (optional)');
$title = _t(__CLASS__ . '.MarkAsReviewedAction', 'Mark as reviewed');
$fields = FieldList::create([
HiddenField::create('ID', null, $object->ID),
HiddenField::cr... | php | {
"resource": ""
} |
q249360 | ReviewContentHandler.submitReview | validation | public function submitReview($record, $data)
{
/** @var DataObject|SiteTreeContentReview $record */
if (!$this->canSubmitReview($record)) {
throw new ValidationException(_t(
__CLASS__ . '.ErrorReviewPermissionDenied',
'It seems you don\'t have the necessar... | php | {
"resource": ""
} |
q249361 | ReviewContentHandler.canSubmitReview | validation | public function canSubmitReview($record)
{
if (!$record->canEdit()
|| !$record->hasMethod('canBeReviewedBy')
|| !$record->canBeReviewedBy(Security::getCurrentUser())
) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q249362 | ContentReviewCMSExtension.ReviewContentForm | validation | public function ReviewContentForm(HTTPRequest $request)
{
// Get ID either from posted back value, or url parameter
$id = $request->param('ID') ?: $request->postVar('ID');
return $this->getReviewContentForm($id);
} | php | {
"resource": ""
} |
q249363 | ContentReviewCMSExtension.getReviewContentForm | validation | public function getReviewContentForm($id)
{
$page = $this->findRecord(['ID' => $id]);
$user = Security::getCurrentUser();
if (!$page->canEdit() || ($page->hasMethod('canBeReviewedBy') && !$page->canBeReviewedBy($user))) {
$this->owner->httpError(403, _t(
__CLASS__... | php | {
"resource": ""
} |
q249364 | ContentReviewCMSExtension.savereview | validation | public function savereview($data, Form $form)
{
$page = $this->findRecord($data);
$results = $this->getReviewContentHandler()->submitReview($page, $data);
if (is_null($results)) {
return null;
}
if ($this->getSchemaRequested()) {
// Send extra "messag... | php | {
"resource": ""
} |
q249365 | ContentReviewCMSExtension.findRecord | validation | protected function findRecord($data)
{
if (empty($data["ID"])) {
throw new HTTPResponse_Exception("No record ID", 404);
}
$page = null;
$id = $data["ID"];
if (is_numeric($id)) {
$page = SiteTree::get()->byID($id);
}
if (!$page || !$page... | php | {
"resource": ""
} |
q249366 | ContentReviewCMSExtension.getSchemaRequested | validation | protected function getSchemaRequested()
{
$parts = $this->owner->getRequest()->getHeader(LeftAndMain::SCHEMA_HEADER);
return !empty($parts);
} | php | {
"resource": ""
} |
q249367 | ContentReviewCMSExtension.getSchemaResponse | validation | protected function getSchemaResponse($schemaID, $form = null, ValidationResult $errors = null, $extraData = [])
{
$parts = $this->owner->getRequest()->getHeader(LeftAndMain::SCHEMA_HEADER);
$data = $this->owner
->getFormSchema()
->getMultipartSchema($parts, $schemaID, $form, ... | php | {
"resource": ""
} |
q249368 | UserIdentity.findByUsernameOrEmail | validation | public static function findByUsernameOrEmail($emailOrUsername)
{
if (filter_var($emailOrUsername, FILTER_VALIDATE_EMAIL)) {
return UserIdentity::findByEmail($emailOrUsername);
}
return UserIdentity::findByUsername($emailOrUsername);
} | php | {
"resource": ""
} |
q249369 | UserIdentity.findByPasswordResetToken | validation | public static function findByPasswordResetToken($id, $code)
{
if (!static::isPasswordResetTokenValid($code)) {
return NULL;
}
return static::findOne([
'id' => $id,
'password_reset_token' => $code,
'status' => self::STATUS_ACTIVE,
]);
} | php | {
"resource": ""
} |
q249370 | ProfileController.actionIndex | validation | public function actionIndex()
{
$profile = Profile::findOne(['uid' => Yii::$app->user->id]);
if ($profile == NULL)
throw new NotFoundHttpException;
return $this->render('index', ['profile' => $profile]);
} | php | {
"resource": ""
} |
q249371 | Twig_Error_Syntax.addSuggestions | validation | public function addSuggestions($name, array $items)
{
if (!$alternatives = self::computeAlternatives($name, $items)) {
return;
}
$this->appendMessage(sprintf(' Did you mean "%s"?', implode('", "', $alternatives)));
} | php | {
"resource": ""
} |
q249372 | Twig_Node_SandboxedPrint.removeNodeFilter | validation | protected function removeNodeFilter(Twig_Node $node)
{
if ($node instanceof Twig_Node_Expression_Filter) {
return $this->removeNodeFilter($node->getNode('node'));
}
return $node;
} | php | {
"resource": ""
} |
q249373 | Twig_Error.getSourceContext | validation | public function getSourceContext()
{
return $this->filename ? new Twig_Source($this->sourceCode, $this->filename, $this->sourcePath) : null;
} | php | {
"resource": ""
} |
q249374 | Twig_Error.setSourceContext | validation | public function setSourceContext(Twig_Source $source = null)
{
if (null === $source) {
$this->sourceCode = $this->filename = $this->sourcePath = null;
} else {
$this->sourceCode = $source->getCode();
$this->filename = $source->getName();
$this->sourceP... | php | {
"resource": ""
} |
q249375 | Twig_TemplateWrapper.renderBlock | validation | public function renderBlock($name, $context = array())
{
$context = $this->env->mergeGlobals($context);
$level = ob_get_level();
ob_start();
try {
$this->template->displayBlock($name, $context);
} catch (Exception $e) {
while (ob_get_level() > $level) ... | php | {
"resource": ""
} |
q249376 | Twig_TemplateWrapper.displayBlock | validation | public function displayBlock($name, $context = array())
{
$this->template->displayBlock($name, $this->env->mergeGlobals($context));
} | php | {
"resource": ""
} |
q249377 | Twig_Environment.setCache | validation | public function setCache($cache)
{
if (is_string($cache)) {
$this->originalCache = $cache;
$this->cache = new Twig_Cache_Filesystem($cache);
} elseif (false === $cache) {
$this->originalCache = $cache;
$this->cache = new Twig_Cache_Null();
} el... | php | {
"resource": ""
} |
q249378 | Twig_Environment.getCacheFilename | validation | public function getCacheFilename($name)
{
@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
$key = $this->cache->generateKey($name, $this->getTemplateClass($name));
return !$key ? false : $key;
} | php | {
"resource": ""
} |
q249379 | Twig_Environment.getTemplateClass | validation | public function getTemplateClass($name, $index = null)
{
$key = $this->getLoader()->getCacheKey($name).$this->optionsHash;
return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '_'.$index);
} | php | {
"resource": ""
} |
q249380 | Twig_Environment.load | validation | public function load($name)
{
if ($name instanceof Twig_TemplateWrapper) {
return $name;
}
if ($name instanceof Twig_Template) {
return new Twig_TemplateWrapper($this, $name);
}
return new Twig_TemplateWrapper($this, $this->loadTemplate($name));
... | php | {
"resource": ""
} |
q249381 | Twig_Environment.createTemplate | validation | public function createTemplate($template)
{
$name = sprintf('__string_template__%s', hash('sha256', $template, false));
$loader = new Twig_Loader_Chain(array(
new Twig_Loader_Array(array($name => $template)),
$current = $this->getLoader(),
));
$this->setLoad... | php | {
"resource": ""
} |
q249382 | Twig_Environment.isTemplateFresh | validation | public function isTemplateFresh($name, $time)
{
if (0 === $this->lastModifiedExtension) {
foreach ($this->extensions as $extension) {
$r = new ReflectionObject($extension);
if (file_exists($r->getFileName()) && ($extensionTime = filemtime($r->getFileName())) > $th... | php | {
"resource": ""
} |
q249383 | Twig_Environment.clearCacheFiles | validation | public function clearCacheFiles()
{
@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
if (is_string($this->originalCache)) {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($th... | php | {
"resource": ""
} |
q249384 | Twig_Environment.getLexer | validation | public function getLexer()
{
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
if (null === $this->lexer) {
$this->lexer = new Twig_Lexer($this);
}
return $this->lexer;
} | php | {
"resource": ""
} |
q249385 | Twig_Environment.tokenize | validation | public function tokenize($source, $name = null)
{
if (!$source instanceof Twig_Source) {
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
$source = new Tw... | php | {
"resource": ""
} |
q249386 | Twig_Environment.getParser | validation | public function getParser()
{
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
if (null === $this->parser) {
$this->parser = new Twig_Parser($this);
}
return $this->parser;
} | php | {
"resource": ""
} |
q249387 | Twig_Environment.parse | validation | public function parse(Twig_TokenStream $stream)
{
if (null === $this->parser) {
$this->parser = new Twig_Parser($this);
}
return $this->parser->parse($stream);
} | php | {
"resource": ""
} |
q249388 | Twig_Environment.getCompiler | validation | public function getCompiler()
{
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
if (null === $this->compiler) {
$this->compiler = new Twig_Compiler($this);
}
return $this->compiler... | php | {
"resource": ""
} |
q249389 | Twig_Environment.compile | validation | public function compile(Twig_NodeInterface $node)
{
if (null === $this->compiler) {
$this->compiler = new Twig_Compiler($this);
}
return $this->compiler->compile($node)->getSource();
} | php | {
"resource": ""
} |
q249390 | Twig_Environment.compileSource | validation | public function compileSource($source, $name = null)
{
if (!$source instanceof Twig_Source) {
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
$source = n... | php | {
"resource": ""
} |
q249391 | Twig_Environment.initRuntime | validation | public function initRuntime()
{
$this->runtimeInitialized = true;
foreach ($this->getExtensions() as $name => $extension) {
if (!$extension instanceof Twig_Extension_InitRuntimeInterface) {
$m = new ReflectionMethod($extension, 'initRuntime');
if ('Twig_... | php | {
"resource": ""
} |
q249392 | Twig_Environment.hasExtension | validation | public function hasExtension($class)
{
$class = ltrim($class, '\\');
if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) {
// For BC/FC with namespaced aliases
$class = new ReflectionClass($class);
$class = $class->name;
}
... | php | {
"resource": ""
} |
q249393 | Twig_Environment.getExtension | validation | public function getExtension($class)
{
$class = ltrim($class, '\\');
if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) {
// For BC/FC with namespaced aliases
$class = new ReflectionClass($class);
$class = $class->name;
}
... | php | {
"resource": ""
} |
q249394 | Twig_Environment.removeExtension | validation | public function removeExtension($name)
{
@trigger_error(sprintf('The %s method is deprecated since version 1.12 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
if ($this->extensionInitialized) {
throw new LogicException(sprintf('Unable to remove extension "%s" as ext... | php | {
"resource": ""
} |
q249395 | Twig_Environment.addFunction | validation | public function addFunction($name, $function = null)
{
if (!$name instanceof Twig_SimpleFunction && !($function instanceof Twig_SimpleFunction || $function instanceof Twig_FunctionInterface)) {
throw new LogicException('A function must be an instance of Twig_FunctionInterface or Twig_SimpleFunct... | php | {
"resource": ""
} |
q249396 | Twig_Environment.addGlobal | validation | public function addGlobal($name, $value)
{
if ($this->extensionInitialized || $this->runtimeInitialized) {
if (null === $this->globals) {
$this->globals = $this->initGlobals();
}
if (!array_key_exists($name, $this->globals)) {
// The depre... | php | {
"resource": ""
} |
q249397 | Twig_Loader_Filesystem.addPath | validation | public function addPath($path, $namespace = self::MAIN_NAMESPACE)
{
// invalidate the cache
$this->cache = $this->errorCache = array();
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
if (!is_dir($checkPath)) {
throw new Twig_Error_Loader(sprin... | php | {
"resource": ""
} |
q249398 | Twig_Loader_Filesystem.prependPath | validation | public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
{
// invalidate the cache
$this->cache = $this->errorCache = array();
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
if (!is_dir($checkPath)) {
throw new Twig_Error_Loader(s... | php | {
"resource": ""
} |
q249399 | User.register | validation | public function register($isSuperAdmin = FALSE, $status = 1)
{
if ($this->getIsNewRecord() == FALSE) {
throw new RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
// Set to 1 if isSuperAdmin is true else set to 0
$this->super_admin = $isSuperAdmin ? 1 : 0;
// Set st... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.