_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q252700
Mail.attachFile
validation
public function attachFile(string $sFileName, string $sContent, string $sType) : bool { $this->_aAttachments[] = array( "name" => $sFileName, "content" => $sContent, "type" => $sType ); return true; }
php
{ "resource": "" }
q252701
Mail.send
validation
public function send() : bool { $sHeaders = 'From: ' . $this->_sFrom . "\r\n"; if (empty($this->_aAttachments)) { if ($this->_sFormat == "HTML") { $sHeaders .= 'MIME-Version: 1.0' . "\r\n"; $sHeaders .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; } return mail(implode(',', $this->_aRecipient), $this->_sSubject, $this->_sMessage, $sHeaders); } else { $sBoundary = "_" . md5(uniqid(rand())); $sAttached = ""; foreach ($this->_aAttachments as $aAttachment) { $sAttached_file = chunk_split(base64_encode($aAttachment["content"])); $sAttached = "\n\n" . "--" . $sBoundary . "\nContent-Type: application; name=\"" . $aAttachment["name"] . "\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment; filename=\"" . $aAttachment["name"] . "\"\r\n\n" . $sAttached_file . "--" . $sBoundary . "--"; } $sHeaders = 'From: ' . $this->_sFrom . "\r\n"; $sHeaders .= "MIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"$sBoundary\"\r\n"; $sBody = "--" . $sBoundary . "\nContent-Type: " . ($this->_sFormat == "HTML" ? "text/html" : "text/plain") . "; charset=UTF-8\r\n\n" . $this->_sMessage . $sAttached; return mail(implode(',', $this->_aRecipient), $this->_sSubject, $sBody, $sHeaders); } }
php
{ "resource": "" }
q252702
ExceptionHandler.enable
validation
public static function enable($state = true, $enable_assert = false){ $state = (bool) $state; self::enableAssert((bool) $enable_assert); if($state && self::$_enabled || !$state && !self::$_enabled){ return; } if($state){ set_exception_handler(__CLASS__ . '::exception'); set_error_handler(__CLASS__ . '::error', error_reporting()); assert_options(ASSERT_CALLBACK, __CLASS__ . '::assert'); self::$_enabled = true; } else{ restore_exception_handler(); restore_error_handler(); /* * According to the PHP documentation this should reset to NULL, * but doing so generates an error when evaluating assertions, so * we instead revert to an empty function... */ assert_options(ASSERT_CALLBACK, function(){}); self::$_enabled = false; } }
php
{ "resource": "" }
q252703
ExceptionHandler.notice
validation
public static function notice($message){ // Remove all superfluous white-spaces for increased readability $message = preg_replace('/\s+/', ' ', $message); static::writeLogLine('Notices.log', $message); trigger_error($message, E_USER_NOTICE); }
php
{ "resource": "" }
q252704
ExceptionHandler.exception
validation
public static function exception($Throwable){ // Dump all output buffers while(@ob_end_clean()); try{ // Command-line interface if(PHP_SAPI == 'cli'){ $message = BaseException::displayConsoleException($Throwable); if(@fwrite(STDERR, $message) === false) echo $message; } // HTTP/1.1 else{ @header("HTTP/1.1 500 Internal Server Error"); @header('Content-Type: text/html'); echo BaseException::displayException($Throwable); } } // Exception while displaying the exception catch(\Throwable $e){ $class = get_class($e); $message = $e->getMessage(); echo "Uncaught $class inside exception-handler: \"$message\""; } exit(1); }
php
{ "resource": "" }
q252705
ExceptionHandler.error
validation
public static function error($severity, $message, $file, $line){ // Respect the "@" error suppression operator if(error_reporting() == 0) return; elseif(error_reporting() && $severity){ $ErrorException = new PHPErrorException( $message, 0, $severity, $file, $line); // If we're in an assert()-chain, *immediately* terminate execution if(assert_options(ASSERT_ACTIVE)){ foreach($ErrorException->getStackTrace() as $element){ if(isset($element['function']) && $element['function'] == 'assert'){ self::exception($ErrorException); } } } $recoverable = [ E_WARNING, E_NOTICE, E_USER_WARNING, E_USER_NOTICE, E_STRICT, E_DEPRECATED, E_USER_DEPRECATED ]; // Only for non-fatal errors if(in_array($severity, $recoverable)){ return; } throw $ErrorException; } }
php
{ "resource": "" }
q252706
ExceptionHandler.assert
validation
public static function assert($file, $line, $expression){ $Exception = new PHPAssertionFailed( '', 0, null, $file, $line, $expression); // Try FireLogger (only if not yet involved) if(assert_options(ASSERT_BAIL)){ // Terminate execution after failed assertion (ASSERT_BAIL) self::exception($Exception); } else{ // Throw the Exception (can be caught; non-fatal) throw $Exception; } }
php
{ "resource": "" }
q252707
ExceptionHandler.writeLogLine
validation
public static function writeLogLine($log_file, $input, $timestamp = null){ if(is_null(self::$_error_folder)){ return false; } // Prevent people from escaping the pre-defined folder $log_file = basename($log_file); $fp = @fopen(self::$_error_folder . $log_file, 'ab'); // NOSONAR if(!$fp){ return false; } if(empty($timestamp)){ $timestamp = time(); } $line = []; $line[] = date(\DateTime::ISO8601, $timestamp); if($input instanceof \Throwable){ $message = $input->getMessage(); if(!($input instanceof BaseException)){ /** * Remove superfluous whitespace from the message (mostly to * prevent the message from spanning multiple lines, making the * log-file more difficult to analyse). * SP\F\BaseException does this in its constructor; our old * BaseException (and external exceptions) will not, so we do it * here for them... */ $message = preg_replace('/\s+/', ' ', $message); } $line[] = BaseException::getShortName(get_class($input)); $line[] = $message; $line[] = $input->getFile(); $line[] = $input->getLine(); $line_out = vsprintf('[%s] %s: %s in %s on line %d', $line); } elseif(is_string($input)){ $line[] = $input; $line_out = vsprintf('[%s] %s', $line); } else{ return false; } // Block until we acquire an exclusive lock if(flock($fp, LOCK_EX)){ fwrite($fp, $line_out . PHP_EOL); flock($fp, LOCK_UN); fclose($fp); return true; } else{ return false; } }
php
{ "resource": "" }
q252708
ClearView.init
validation
public function init(array $viewDirs, array $params) { $this->viewDirs = $viewDirs; $this->params = $params; $this->parts = new ClearViewPartsCollection(); }
php
{ "resource": "" }
q252709
ResponseResourceController.index
validation
public function index(ResponseRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Forum\Repositories\Presenter\ResponsePresenter::class) ->$function(); } $responses = $this->repository->paginate(); return $this->response->title(trans('forum::response.names')) ->view('forum::response.index', true) ->data(compact('responses')) ->output(); }
php
{ "resource": "" }
q252710
ResponseResourceController.show
validation
public function show(ResponseRequest $request, Response $response) { if ($response->exists) { $view = 'forum::response.show'; } else { $view = 'forum::response.new'; } return $this->response->title(trans('app.view') . ' ' . trans('forum::response.name')) ->data(compact('response')) ->view($view, true) ->output(); }
php
{ "resource": "" }
q252711
ResponseResourceController.store
validation
public function store(ResponseRequest $request) { try { $request = $request->all(); $slug = $request['slug']; $attributes['comment'] = $request['comment']; $attributes['question_id'] = $request['question_id']; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $response = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('forum::response.name')])) ->code(204) ->status('success') ->url(trans_url('/discussion/'.$slug)) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(trans_url('/question/'.$slug)) ->redirect(); } }
php
{ "resource": "" }
q252712
ResponseResourceController.edit
validation
public function edit(ResponseRequest $request, Response $response) { return $this->response->title(trans('app.edit') . ' ' . trans('forum::response.name')) ->view('forum::response.edit', true) ->data(compact('response')) ->output(); }
php
{ "resource": "" }
q252713
ResponseResourceController.update
validation
public function update(ResponseRequest $request, Response $response) { try { $attributes = $request->all(); $id = $attributes['question_id']; $question = $this->question->selectquestion($id); $response->update($attributes); return redirect('/discussion/'.$question['slug']); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('forum/response/' . $response->getRouteKey())) ->redirect(); } }
php
{ "resource": "" }
q252714
ResponseResourceController.destroy
validation
public function destroy(ResponseRequest $request, Response $response) { try { $id = $response['question_id']; $question = $this->question->selectquestion($id); $response->delete(); return redirect('/discussion/'.$question['slug']); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('forum/response/' . $response->getRouteKey())) ->redirect(); } }
php
{ "resource": "" }
q252715
ObjectViewEvent.setObject
validation
public function setObject($object) { if (is_null($this->_objectType)) { $this->objectType = $object->objectType; } $this->_object = $object; }
php
{ "resource": "" }
q252716
ObjectViewEvent.setObjectType
validation
public function setObjectType($type) { if (!is_object($type)) { if (Yii::$app->collectors['types']->has($type)) { $type = Yii::$app->collectors['types']->getOne($type)->object; } else { $type = null; } } $this->_objectType = $type; }
php
{ "resource": "" }
q252717
Benri_Auth.authenticate
validation
public function authenticate(Zend_Auth_Adapter_Interface $adapter) { // Authenticates against the supplied adapter. $result = $adapter->authenticate(); /* * ZF-7546 - prevent multiple succesive calls from storing inconsistent * results. * * Ensure storage has clean state. */ if ($this->hasIdentity()) { $this->clearIdentity(); } if ($result->isValid()) { $this->getStorage() ->write($adapter->getResultRowObject()); } return $result; }
php
{ "resource": "" }
q252718
Theme.boot
validation
public function boot(Plugin $theme) { $this->plugin = $theme; parent::boot($theme); $this->initTemplates(); $this->initHomepageTemplate(); return $this; }
php
{ "resource": "" }
q252719
Theme.addTemplateSlots
validation
public function addTemplateSlots($templateName, $username) { if (!array_key_exists($templateName, $this->templateBlocks)) { return null; } $blocks = $this->templateBlocks[$templateName]; $this->addSlots($blocks, $username); }
php
{ "resource": "" }
q252720
Client.send
validation
protected function send(RequestInterface $request): ResponseInterface { $request = $request->withHeader("Authorization", sprintf("Bearer %s", $this->apiToken)); $request = $request->withHeader("Content-Type", "application/json"); $request = $request->withHeader("Accept", "application/json"); try { $response = $this->client->send($request); } catch (GuzzleException $e) { if ($e->getCode() === 401) { throw new ClientException("Authorization failed. Did you specify the right api token?", $request, null, $e); } throw new ClientException(sprintf("Failed to execute request (code %d): %s", $e->getCode(), $e->getMessage()), $request, null, $e); } return $response; }
php
{ "resource": "" }
q252721
Client.getJsonBody
validation
private function getJsonBody(RequestInterface $request, ResponseInterface $response): array { $data = json_decode($response->getBody(), true); if (!$data || !is_array($data) || !array_key_exists("data", $data)) { throw new ClientException("Response body does not contain a valid JSON object.", $request, $response); } if (!is_array($data) || !is_array($data["data"])) { throw new ClientException("Not sure what happened. The list jobs endpoint didn't return a list. :worried:", $request, $response); } return $data["data"]; }
php
{ "resource": "" }
q252722
Deployer.save
validation
public function save(BlockManagerApprover $approver, array $options, $saveCommonSlots = true) { $this->contributorDefined(); $filesystem = new Filesystem(); $pageDir = $this->pagesDir . '/' . $options["page"]; $filesystem->copy($pageDir . '/' . $this->pageFile, $pageDir . '/page.json', true); $pageDir .= '/' . $options["language"] . '_' . $options["country"]; if ($this->seoFile != "seo.json") { $sourceFile = $pageDir . '/' . $this->seoFile; $values = json_decode(file_get_contents($sourceFile), true); if (array_key_exists("current_permalink", $values)) { $values["changed_permalinks"][] = $values["current_permalink"]; unset($values["current_permalink"]); file_put_contents($sourceFile, json_encode($values)); } $filesystem->copy($sourceFile, $pageDir . '/seo.json', true); } $approvedBlocks = $this->saveBlocks($approver, $pageDir, $options); if ($saveCommonSlots) { $slotsDir = $this->baseDir . '/slots'; $approvedCommonBlocks = $this->saveBlocks($approver, $slotsDir, $options); $approvedBlocks = array_merge($approvedBlocks, $approvedCommonBlocks); } Dispatcher::dispatch(PageEvents::PAGE_SAVED, new PageSavedEvent($pageDir, null, $approvedBlocks)); DataLogger::log(sprintf('Page "%s" was successfully saved in production', $options["page"])); }
php
{ "resource": "" }
q252723
Deployer.saveAllPages
validation
public function saveAllPages(BlockManagerApprover $approver, array $languages, $saveCommonSlots = true) { $this->contributorDefined(); $finder = new Finder(); $pages = $finder->directories()->depth(0)->in($this->pagesDir); foreach ($pages as $page) { $page = (string)$page; $pageName = basename($page); foreach ($languages as $language) { $tokens = explode("_", $language); $options = array( 'page' => $pageName, 'language' => $tokens[0], 'country' => $tokens[1], ); $this->save($approver, $options, $saveCommonSlots); } $saveCommonSlots = false; } Dispatcher::dispatch(PageCollectionEvents::SITE_SAVED, new SiteSavedEvent()); DataLogger::log('The whole website\'s pages were successfully saved in production'); }
php
{ "resource": "" }
q252724
Container.getFactory
validation
public function getFactory($class, array $params = array()) { if (!isset($this->factories[$class]) && $this->autowire) { $this->factories[$class] = Definition::getDefaultForClass($class); } $factory = $this->factories[$class]; // if $params is defined, we need to either make a copy of the existing // Factory or make the Definition create a new factory with the params if ($params) { $factory = $factory->getFactory($params); } return $factory; }
php
{ "resource": "" }
q252725
Container.getFunctionArguments
validation
protected function getFunctionArguments(ReflectionFunctionAbstract $func, array $params = array()) { $args = []; foreach ($func->getParameters() as $param) { $class = $param->getClass(); if ($class) { $args[] = $this->resolveClassArg($class, $param, $params); } else { $args[] = $this->resolveNonClassArg($param, $params, $func); } } return $args; }
php
{ "resource": "" }
q252726
Container.resolveClassArg
validation
protected function resolveClassArg(ReflectionClass $class, ReflectionParameter $param, array $params) { $name = '$'.$param->getName(); $class = $class->getName(); // loop to prevent code repetition. executes once trying to find the // parameter name in the $params array, then once more trying to find // the class name (typehint) of the parameter. while ($name !== null) { if ($params && array_key_exists($name, $params)) { $class = $params[$name]; } if ($class instanceof Factory\FactoryInterface) { return $class->invoke($this); } if (is_object($class)) { return $class; } $name = ($name != $class) ? $class : null; } try { return $this->resolve($class); } catch (ReflectionException $exception) { if ($param->isOptional()) { return null; } throw $exception; } }
php
{ "resource": "" }
q252727
Container.resolveNonClassArg
validation
protected function resolveNonClassArg(ReflectionParameter $param, array $params, ReflectionFunctionAbstract $func) { $name = '$'.$param->getName(); if ($params && array_key_exists($name, $params)) { $argument = $params[$name]; if (is_array($argument) && isset($this->factories[$argument[0]])) { $argument = $this->callFactory($argument[0], $argument[1]); } return $argument; } if ($param->isDefaultValueAvailable()) { return $param->getDefaultValue(); } throw Exception\UnresolvableArgumentException::fromReflectionParam($param, $func); }
php
{ "resource": "" }
q252728
Container.callResolvingCallbacks
validation
protected function callResolvingCallbacks($key, $object) { foreach ($this->resolvingAnyCallbacks as $callback) { call_user_func($callback, $object, $this); } if (isset($this->resolvingCallbacks[$key])) { foreach ($this->resolvingCallbacks[$key] as $callback) { call_user_func($callback, $object, $this); } } }
php
{ "resource": "" }
q252729
Session.setName
validation
public function setName(string $name): void { if (!empty($name)) { if (!is_numeric($name)) { @session_name($name); } else { throw new Exception('The session name can\'t consist only of digits, ' .'at least one letter must be presented.'); } } else { throw new Exception('Empty session name value was passed.'); } }
php
{ "resource": "" }
q252730
Session.start
validation
public function start(?string $name = null, ?string $sessionId = null): string { if (!$this->isStarted()) { if (!is_null($name)) { $this->setName($name); } @session_start($sessionId); }; return $this->getId(); }
php
{ "resource": "" }
q252731
Session.destroyWithCookie
validation
public function destroyWithCookie(): ?bool { if ($this->isStarted()) { $this->destroy(); return setcookie($this->getName(), '', time() - 1, '/'); } return null; }
php
{ "resource": "" }
q252732
Session.getAll
validation
public function getAll(): array { $res = []; foreach ($this->getKeys() as $key) { $res[$key] = $this->get($key); } return $res; }
php
{ "resource": "" }
q252733
Session.remove
validation
public function remove(string $key) { if ($this->contains($key)) { $res = $_SESSION[$key]; unset($_SESSION[$key]); return $res; } else { return null; } }
php
{ "resource": "" }
q252734
Session.removeAll
validation
public function removeAll(): array { $res = []; foreach ($this->getKeys() as $key) { $res[$key] = $this->remove($key); } return $res; }
php
{ "resource": "" }
q252735
DataLogger.log
validation
public static function log($message, $type = DataLogger::INFO) { if (null === self::$logger) { return; } if (!method_exists(self::$logger, $type)) { $exceptionMessage = sprintf('Logger does not support the %s method.', $type); throw new \InvalidArgumentException($exceptionMessage); } self::$logger->$type($message); }
php
{ "resource": "" }
q252736
ShowPageCollectionController.showAction
validation
public function showAction(Request $request, Application $app) { $options = array( "request" => $request, "configuration_handler" => $app["red_kite_cms.configuration_handler"], "page_collection_manager" => $app["red_kite_cms.page_collection_manager"], 'form_factory' => $app["form.factory"], "pages_collection_parser" => $app["red_kite_cms.pages_collection_parser"], "username" => $this->fetchUsername($app["security"], $app["red_kite_cms.configuration_handler"]), 'theme' => $app["red_kite_cms.theme"], 'template_assets' => $app["red_kite_cms.template_assets"], 'twig' => $app["twig"], ); return parent::show($options); }
php
{ "resource": "" }
q252737
LoadTime.end
validation
public static function end() { if (self::$startTime) { $time = round((microtime(true) - self::$startTime), 4); self::$startTime = false; } return (isset($time)) ? $time : false; }
php
{ "resource": "" }
q252738
Benri_Db_Table.all
validation
public static function all($pageNumber = 0, $pageSize = 10, $order = null) { return (new static()) ->fetchAll(null, $order, $pageSize, $pageNumber); }
php
{ "resource": "" }
q252739
Benri_Db_Table.locate
validation
public static function locate($column, $value) { $table = new static(); $select = $table->select() ->where("{$table->getAdapter()->quoteIdentifier($column)} = ?", $value) ->limit(1); return $table->fetchRow($select); }
php
{ "resource": "" }
q252740
Benri_Db_Table.bulkInsert
validation
public static function bulkInsert(array $batch) { $table = new static(); if (1 === sizeof($batch)) { return $table->insert(array_shift($batch)); } $adapter = $table->getAdapter(); $counter = 0; $sqlBinds = []; $values = []; // // Do some voodoo here... foreach ($batch as $i => $row) { $placeholders = []; foreach ($row as $column => $value) { ++$counter; if ($adapter->supportsParameters('positional')) { $placeholders[] = '?'; $values[] = $value; } elseif ($adapter->supportsParameters('named')) { $name = ":col{$i}{$counter}"; $placeholders[] = $name; $values[$name] = $value; } else { throw new Zend_Db_Adapter_Exception(sprintf( '%s doesn\'t support positional or named binding', get_class($table) )); } } // // and more blacky magic over here... $sqlBinds[] = '(' . implode(',', $placeholders) . ')'; } // // extract column names... $columns = array_keys($row); // // and quoteIdentifier() them. array_walk($columns, function (&$index) use ($adapter) { $index = $adapter->quoteIdentifier($index, true); }); // // Shit, shit, shit! F U ZF. $spec = $adapter->quoteIdentifier( ($table->_schema ? "{$table->_schema}." : '') . $table->_name ); // // Build the SQL using the placeholders... $sql = sprintf( 'INSERT INTO %s (%s) VALUES %s', $spec, // fully table name implode(',', $columns), // column names implode(',', $sqlBinds) // placeholders ); // Ready? $stmt = $adapter->prepare($sql); // // Fight! $stmt->execute($values); // // aaaaaaand voilá! return $stmt->rowCount(); }
php
{ "resource": "" }
q252741
Benri_Db_Table._setupDatabaseAdapter
validation
protected function _setupDatabaseAdapter() { if (Zend_Registry::isRegistered('multidb')) { return $this->_setAdapter(Zend_Registry::get('multidb')->getDb($this->_connection)); } return parent::_setupDatabaseAdapter(); }
php
{ "resource": "" }
q252742
Aura.loadContainer
validation
protected function loadContainer(array $config = [], $environment = null) { $containerConfigs = $this->provideContainerConfigs($config, $environment); array_unshift( $containerConfigs, new WeaveConfig( function ($pipelineName) { return $this->provideMiddlewarePipeline($pipelineName); }, function ($router) { return $this->provideRouteConfiguration($router); } ) ); $this->container = (new ContainerBuilder)->newConfiguredInstance( $containerConfigs, ContainerBuilder::AUTO_RESOLVE ); return $this->container->get('instantiator'); }
php
{ "resource": "" }
q252743
CommentController.showAction
validation
public function showAction(Comment $comment) { $deleteForm = $this->createDeleteForm($comment); return array( 'entity' => $comment, 'delete_form' => $deleteForm->createView(), ); }
php
{ "resource": "" }
q252744
CommentController.createDeleteForm
validation
private function createDeleteForm(Comment $comment) { return $this->createFormBuilder() ->setAction($this->generateUrl('blog_comment_delete', array('id' => $comment->getId()))) ->setMethod('DELETE') ->getForm() ; }
php
{ "resource": "" }
q252745
SlotMap.setSlots
validation
public function setSlots($first, $last, $connection) { if (!static::isValidRange($first, $last)) { throw new \OutOfBoundsException("Invalid slot range $first-$last for `$connection`"); } $this->slots += array_fill($first, $last - $first + 1, (string) $connection); }
php
{ "resource": "" }
q252746
SlotMap.getSlots
validation
public function getSlots($first, $last) { if (!static::isValidRange($first, $last)) { throw new \OutOfBoundsException("Invalid slot range $first-$last"); } return array_intersect_key($this->slots, array_fill($first, $last - $first + 1, null)); }
php
{ "resource": "" }
q252747
SlotMap.offsetSet
validation
public function offsetSet($slot, $connection) { if (!static::isValid($slot)) { throw new \OutOfBoundsException("Invalid slot $slot for `$connection`"); } $this->slots[(int) $slot] = (string) $connection; }
php
{ "resource": "" }
q252748
Guard.serve
validation
public function serve() { Log::debug('Request received:', [ 'Method' => $this->request->getMethod(), 'URI' => $this->request->getRequestUri(), 'Query' => $this->request->getQueryString(), 'Protocal' => $this->request->server->get('SERVER_PROTOCOL'), 'Content' => $this->request->getContent(), ]); $this->validate($this->token); if ($str = $this->request->get('echostr')) { Log::debug("Output 'echostr' is '$str'."); return new Response($str); } $result = $this->handleRequest(); $response = $this->buildResponse($result['to'], $result['from'], $result['response']); Log::debug('Server response created:', compact('response')); return new Response($response); }
php
{ "resource": "" }
q252749
Guard.validate
validation
public function validate($token) { $params = [ $token, $this->request->get('timestamp'), $this->request->get('nonce'), ]; if (!$this->debug && $this->request->get('signature') !== $this->signature($params)) { throw new FaultException('Invalid request signature.', 400); } }
php
{ "resource": "" }
q252750
Guard.parseMessageFromRequest
validation
protected function parseMessageFromRequest($content) { $content = strval($content); $dataSet = json_decode($content, true); if ($dataSet && (JSON_ERROR_NONE === json_last_error())) { // For mini-program JSON formats. // Convert to XML if the given string can be decode into a data array. $content = XML::build($dataSet); } if ($this->isSafeMode()) { if (!$this->encryptor) { throw new RuntimeException('Safe mode Encryptor is necessary, please use Guard::setEncryptor(Encryptor $encryptor) set the encryptor instance.'); } $message = $this->encryptor->decryptMsg( $this->request->get('msg_signature'), $this->request->get('nonce'), $this->request->get('timestamp'), $content ); } else { $message = XML::parse($content); } return $message; }
php
{ "resource": "" }
q252751
Parser.parse
validation
public static function parse($program) { $i = 0; $len = strlen($program); $forms = []; while ($i < $len) { if (strpos(self::WHITESPACES, $program[$i]) === false) { try { $form = self::parseExpression(substr($program, $i), $offset); if (!is_null($form)) $forms[] = $form; } catch (ParseException $e) { throw new ParseException($program, $e->offset + $i); } $i += $offset; } else ++$i; } return $forms; }
php
{ "resource": "" }
q252752
Parser.unescapeString
validation
protected static function unescapeString($matches) { static $map = ['n' => "\n", 'r' => "\r", 't' => "\t", 'v' => "\v", 'f' => "\f"]; if (!empty($matches[2])) return chr(octdec($matches[2])); elseif (!empty($matches[3])) return chr(hexdec($matches[3])); elseif (isset($map[$matches[1]])) return $map[$matches[1]]; return $matches[1]; }
php
{ "resource": "" }
q252753
RecoveryController.actionRequest
validation
public function actionRequest() { if (!$this->module->enablePasswordRecovery) { throw new NotFoundHttpException; } $model = \Yii::createObject([ 'class' => RecoveryForm::className(), 'scenario' => 'request', ]); $this->performAjaxValidation($model); if ($model->load(\Yii::$app->request->post()) && $model->sendRecoveryMessage()) { return $this->render('/message', [ 'title' => \Yii::t('user', 'Recovery message sent'), 'module' => $this->module, ]); } return $this->render('request', [ 'model' => $model, ]); }
php
{ "resource": "" }
q252754
RecoveryController.actionReset
validation
public function actionReset($id, $code) { if (!$this->module->enablePasswordRecovery) { throw new NotFoundHttpException; } /** @var Token $token */ $token = $this->finder->findToken(['user_id' => $id, 'code' => $code, 'type' => Token::TYPE_RECOVERY])->one(); if ($token === null || $token->isExpired || $token->user === null) { \Yii::$app->session->setFlash('danger', \Yii::t('user', 'Recovery link is invalid or expired. Please try requesting a new one.')); return $this->render('/message', [ 'title' => \Yii::t('user', 'Invalid or expired link'), 'module' => $this->module, ]); } $model = \Yii::createObject([ 'class' => RecoveryForm::className(), 'scenario' => 'reset', ]); $this->performAjaxValidation($model); if ($model->load(\Yii::$app->getRequest()->post()) && $model->resetPassword($token)) { return $this->render('/message', [ 'title' => \Yii::t('user', 'Password has been changed'), 'module' => $this->module, ]); } return $this->render('reset', [ 'model' => $model, ]); }
php
{ "resource": "" }
q252755
PsrRequestAdapter.getNamedParams
validation
public function getNamedParams(string $category = null) : array { switch($category) { case 'attribute': return $this->request->getAttributes(); case 'query': return $this->request->getQueryParams(); case 'uploaded_files': return $this->request->getUploadedFiles(); case 'parsed_body': { $body = $this->request->getParsedBody(); if (!$body){ return []; } if (is_array($body)){ return $body; } if (is_object($body)){ return get_object_vars($body); } } return []; case 'server': return $this->request->getServerParams(); case 'cookie': return $this->request->getCookieParams(); } return []; }
php
{ "resource": "" }
q252756
PsrRequestAdapter.getNamedParam
validation
public function getNamedParam(string $category, string $key) { $params = $this->getNamedParams($category); return $params[$key] ?? ''; }
php
{ "resource": "" }
q252757
SEO_Icons_SiteTree_DataExtension.updateMetadata
validation
public function updateMetadata(SiteConfig $config, SiteTree $owner, &$metadata) { //// HTML4 Favicon // @todo Perhaps create dynamic image, but just use favicon.ico for now //// Create Favicons $HTML5Favicon = $config->HTML5Favicon(); $IOSPinicon = $config->IOSPinicon(); $AndroidPinicon = $config->AndroidPinicon(); $WindowsPinicon = $config->WindowsPinicon(); //// iOS Pinicon if ($IOSPinicon->exists()) { $this->GenerateIOSPinicon($config, $owner, $metadata, $IOSPinicon); } //// HTML5 Favicon if ($HTML5Favicon->exists()) { $this->GenerateHTML5Favicon($owner, $metadata, $HTML5Favicon); } //// Android Pinicon Manifest if ($AndroidPinicon->exists()) { $this->GenerateAndroidPinicon($config, $owner, $metadata); } //// Windows Pinicon Manifest if ($WindowsPinicon->exists()) { $this->GenerateWindowsPinicon($config, $owner, $metadata, $WindowsPinicon); } }
php
{ "resource": "" }
q252758
SEO_Icons_SiteTree_DataExtension.GenerateIOSPinicon
validation
protected function GenerateIOSPinicon(SiteConfig $config, SiteTree $owner, &$metadata, Image $IOSPinicon) { // header $metadata .= $this->owner->MarkupComment('iOS Pinned Icon'); //// iOS Pinicon Title if ($config->fetchPiniconTitle()) { $metadata .= $owner->MarkupMeta('apple-mobile-web-app-title', $config->fetchPiniconTitle()); } //// iOS Pinned Icon // For non-Retina (@1× display) iPhone, iPod Touch, and Android 2.1+ devices $metadata .= $owner->MarkupLink('apple-touch-icon', $IOSPinicon->Fill(57, 57)->getAbsoluteURL(), 'image/png'); // 57×57 // @todo: What is this for ?? $metadata .= $owner->MarkupLink('apple-touch-icon', $IOSPinicon->Fill(60, 60)->getAbsoluteURL(), 'image/png', '60x60'); // For the iPad mini and the first- and second-generation iPad (@1× display) on iOS ≤ 6 $metadata .= $owner->MarkupLink('apple-touch-icon', $IOSPinicon->Fill(72, 72)->getAbsoluteURL(), 'image/png', '72x72'); // For the iPad mini and the first- and second-generation iPad (@1× display) on iOS ≥ 7 $metadata .= $owner->MarkupLink('apple-touch-icon', $IOSPinicon->Fill(76, 76)->getAbsoluteURL(), 'image/png', '76x76'); // For iPhone with @2× display running iOS ≤ 6 $metadata .= $owner->MarkupLink('apple-touch-icon', $IOSPinicon->Fill(114, 114)->getAbsoluteURL(), 'image/png', '114x114'); // For iPhone with @2× display running iOS ≥ 7 $metadata .= $owner->MarkupLink('apple-touch-icon', $IOSPinicon->Fill(120, 120)->getAbsoluteURL(), 'image/png', '120x120'); // For iPad with @2× display running iOS ≤ 6 $metadata .= $owner->MarkupLink('apple-touch-icon', $IOSPinicon->Fill(144, 144)->getAbsoluteURL(), 'image/png', '144x144'); // For iPad with @2× display running iOS ≥ 7 $metadata .= $owner->MarkupLink('apple-touch-icon', $IOSPinicon->Fill(152, 152)->getAbsoluteURL(), 'image/png', '152x152'); // For iPhone 6 Plus with @3× display $metadata .= $owner->MarkupLink('apple-touch-icon', $IOSPinicon->Fill(180, 180)->getAbsoluteURL(), 'image/png', '180x180'); }
php
{ "resource": "" }
q252759
SEO_Icons_SiteTree_DataExtension.GenerateHTML5Favicon
validation
protected function GenerateHTML5Favicon(SiteTree $owner, &$metadata, Image $HTML5Favicon) { // header $metadata .= $owner->MarkupComment('HTML5 Favicon'); // // Android Chrome 32 // @todo: Is the Android Chrome 32 196x196 px icon fully redundant ?? // $metadata .= $owner->MarkupLink('icon', $HTML5Favicon->Fill(196,196)->getAbsoluteURL(), 'image/png', '196x196'); // Android Chrome 37+ / HTML5 spec $metadata .= $owner->MarkupLink('icon', $HTML5Favicon->Fill(192, 192)->getAbsoluteURL(), 'image/png', '192x192'); // Android Chrome 37+ / HTML5 spec $metadata .= $owner->MarkupLink('icon', $HTML5Favicon->Fill(128, 128)->getAbsoluteURL(), 'image/png', '128x128'); // For Google TV $metadata .= $owner->MarkupLink('icon', $HTML5Favicon->Fill(96, 96)->getAbsoluteURL(), 'image/png', '96x96'); // For Safari on Mac OS $metadata .= $owner->MarkupLink('icon', $HTML5Favicon->Fill(32, 32)->getAbsoluteURL(), 'image/png', '32x32'); // The classic favicon, displayed in the tabs $metadata .= $owner->MarkupLink('icon', $HTML5Favicon->Fill(16, 16)->getAbsoluteURL(), 'image/png', '16x16'); }
php
{ "resource": "" }
q252760
SEO_Icons_SiteTree_DataExtension.GenerateAndroidPinicon
validation
protected function GenerateAndroidPinicon(SiteConfig $config, SiteTree $owner, &$metadata) { // header $metadata .= $owner->MarkupComment('Android Pinned Icon'); // if ($config->fetchAndroidPiniconThemeColor()) { $metadata .= $owner->MarkupMeta('theme-color', $config->fetchAndroidPiniconThemeColor()); } // $metadata .= $owner->MarkupLink('manifest', '/manifest.json'); }
php
{ "resource": "" }
q252761
SEO_Icons_SiteTree_DataExtension.GenerateWindowsPinicon
validation
protected function GenerateWindowsPinicon(SiteConfig $config, SiteTree $owner, &$metadata, Image $WindowsPinicon) { // header $metadata .= $owner->MarkupComment('Windows Pinned Icon'); // application name $appName = $config->fetchPiniconTitle(); if (!$appName) { $appName = $config->Title; } $metadata .= $owner->MarkupMeta('application-name', $appName); // tile background color if ($config->fetchWindowsPiniconBackgroundColor()) { $metadata .= $owner->MarkupMeta('msapplication-TileColor', $config->fetchWindowsPiniconBackgroundColor()); } // small tile $metadata .= $owner->MarkupMeta('msapplication-square70x70logo', $WindowsPinicon->Fill(70, 70)->getAbsoluteURL()); // medium tile $metadata .= $owner->MarkupMeta('msapplication-square150x150logo', $WindowsPinicon->Fill(150, 150)->getAbsoluteURL()); // @todo: Implement wide & tall tiles // wide tile // $metadata .= $owner->MarkupMeta('msapplication-square310x150logo', $WindowsPinicon->Fill(310,150)->getAbsoluteURL()); // large tile // $metadata .= $owner->MarkupMeta('msapplication-square310x310logo', $WindowsPinicon->Fill(310,310)->getAbsoluteURL()); }
php
{ "resource": "" }
q252762
EventMediator.off
validation
public function off($eventType, $listener = null) { foreach ($this->_eventListeners as $i => $l) { if ($l->getType() == $eventType) { if ($listener === null || $l->getListener() === $listener) { unset($this->_eventListeners[$i]); } } } }
php
{ "resource": "" }
q252763
AuditPackage.get
validation
public function get($name) { return isset($this->_items[$name]) ? $this->_items[$name] : null; }
php
{ "resource": "" }
q252764
BotDomParser.parseBotNames
validation
public function parseBotNames() { $dom = $this->getDom('https://udger.com/resources/ua-list/crawlers'); if (false === $dom) { throw new Exception("Fail to load bot list DOM.", E_WARNING); } $crawler = new Crawler(); $crawler->addContent($dom); $crawler->filter('body #container table tr td > a')->each(function($node, $i) { $botName = $node->text(); $this->addBotName($botName); }); }
php
{ "resource": "" }
q252765
BotDomParser.parseBotUA
validation
public function parseBotUA($botName) { $dom = $this->getDom('https://udger.com/resources/ua-list/bot-detail?bot=' . $botName); if (false === $dom) { echo "Can not parse DOM" . PHP_EOL; return false; } $this->currentBotName = $botName; $crawlerBot = new Crawler(); $crawlerBot->addContent($dom); $crawlerBot->filter('body #container table tr td > a')->each(function($el, $i) { if (strpos($el->attr('href'), '/resources/online-parser') !== false) { $botUA = $el->text(); $this->addBotUA($botUA); } }); return true; }
php
{ "resource": "" }
q252766
BotDomParser.getDom
validation
private function getDom($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $dom = curl_exec($ch); curl_close($ch); return $dom; }
php
{ "resource": "" }
q252767
FileResolver.resolve
validation
public function resolve($templatePath) { $templatePathReal = realpath($templatePath); if ($templatePathReal === false) { throw new \Exception( 'Template file does not exist: ' . $templatePath ); } if ($this->hasCache($templatePathReal)) { return $this->getCache($templatePathReal); } $template = file_get_contents( $templatePathReal ); $this->setCache($templatePathReal, $template); return $template; }
php
{ "resource": "" }
q252768
LaravelHelpersServiceProvider.registerPackageHelpers
validation
public function registerPackageHelpers() { foreach($this->packageHelpers as $helper) { $dashName = last(explode('/', $helper)); $underscoreName = str_replace('-', '_', $dashName); if(in_array('*', $this->packageInclude) || in_array($dashName, $this->packageInclude) || in_array($underscoreName, $this->packageInclude)) { require_once $this->replaceVariables($this->packageHelperPattern, compact('dashName', 'underscoreName')); } } }
php
{ "resource": "" }
q252769
LaravelHelpersServiceProvider.registerCustomHelpers
validation
public function registerCustomHelpers() { foreach(glob(app_path($this->namespace.'/*')) as $helper) { $helperName = last(explode('/', $helper)); if(!in_array($helperName, $this->customExclude)) { if(in_array('*', $this->customInclude) || in_array($helperName, $this->customInclude)) { require_once $helper; } } } }
php
{ "resource": "" }
q252770
LaravelHelpersServiceProvider.replaceVariables
validation
public function replaceVariables($string, $replaces = []) { $callback = function ($match) use ($replaces) { $variable = trim($match[0], '{}'); if(array_key_exists($variable, $replaces)) { return $replaces[$variable]; } return $variable; }; return preg_replace_callback('/{.*?}/', $callback, $string); }
php
{ "resource": "" }
q252771
Path.setPermissions
validation
public static function setPermissions($path, $mode=0777, $recursive=true) { $path = Path::clean($path); $fs = new Filesystem(); try { $fs->chmod($path, $mode, 0000, $recursive); } catch(IOExceptionInterface $e){ return false; } return true; }
php
{ "resource": "" }
q252772
FilesystemTools.slotDir
validation
public static function slotDir($sourceDir, array $options) { $paths = array( sprintf( '%s/pages/pages/%s/%s_%s/%s', $sourceDir, $options['page'], $options['language'], $options['country'], $options['slot'] ), sprintf('%s/slots/%s/%s_%s', $sourceDir, $options['slot'], $options['language'], $options['country']), sprintf('%s/slots/%s', $sourceDir, $options['slot']), ); return self::cascade($paths); }
php
{ "resource": "" }
q252773
FilesystemTools.cascade
validation
public static function cascade(array $folders) { $result = null; foreach ($folders as $folder) { if (is_dir($folder)) { $result = $folder; break; } } return $result; }
php
{ "resource": "" }
q252774
FilesystemTools.readFile
validation
public static function readFile($file) { if (!file_exists($file)) { return null; } $handle = fopen($file, 'r'); if (!self::lockFile($handle, LOCK_SH | LOCK_NB)) { $exception = array( "message" => 'exception_file_cannot_be_locked_for_reading', "parameters" => array( "%file%" => basename($file), ) ); throw new RuntimeException(json_encode($exception)); } $contents = file_get_contents($file); self::unlockFile($handle); return $contents; }
php
{ "resource": "" }
q252775
FilesystemTools.writeFile
validation
public static function writeFile($file, $content) { $handle = fopen($file, 'w'); if (!self::lockFile($handle, LOCK_EX | LOCK_NB)) { $exception = array( "message" => 'exception_file_cannot_be_locked_for_writing', "parameters" => array( "%file%" => basename($file), ) ); throw new RuntimeException(json_encode($exception)); } if (fwrite($handle, $content) === false) { $exception = array( "message" => 'exception_file_cannot_be_written', "parameters" => array( "%file%" => basename($file), ) ); throw new RuntimeException(json_encode($exception)); } self::unlockFile($handle); }
php
{ "resource": "" }
q252776
ModuleSetExtension.bootstrap
validation
public function bootstrap($app) { Yii::beginProfile(get_called_class()); Yii::$app->modules = static::getModules(); Yii::$app->on(\yii\base\Application::EVENT_BEFORE_REQUEST, [$this, 'beforeRequest']); Yii::endProfile(get_called_class()); Yii::trace("Registered " . count(static::getModules()) . " modules in " . get_called_class()); }
php
{ "resource": "" }
q252777
Time.cast
validation
public static function cast($time) { return $time instanceof self ? $time : new self($time->format(self::ISO8601), $time->getTimezone()); }
php
{ "resource": "" }
q252778
HttpRequest.get
validation
public function get($name, $default = "") { $param = Arr::get($_REQUEST, $name, $default); if ($_SERVER["REQUEST_METHOD"] == "GET" && is_string($param)) { $param = urldecode($param); } return $param; }
php
{ "resource": "" }
q252779
Generator.setItems
validation
public function setItems($items) { $this->_items = $items; if (isset($this->_items[0]) && is_array($this->_items[0])) { $this->_items = $this->_items[0]; } foreach ($this->_items as $item) { $item->owner = $this; if (!$item->isValid) { $this->isValid = false; } } }
php
{ "resource": "" }
q252780
BlockManagerAdd.add
validation
public function add($sourceDir, array $options, $username) { $this->resolveAddOptions($options); $this->createContributorDir($sourceDir, $options, $username); $dir = $this ->init($sourceDir, $options, $username) ->getDirInUse() ; $blockName = $this->addBlockToSlot($dir, $options); $blockContent = $this->addBlock($dir, $options, $blockName); DataLogger::log( sprintf( 'Block "%s" has been added to the "%s" slot on page "%s" for the "%s_%s" language', $blockName, $options["slot"], $options["page"], $options["language"], $options["country"] ) ); return $blockContent; }
php
{ "resource": "" }
q252781
BlockManagerAdd.resolveAddOptions
validation
protected function resolveAddOptions(array $options) { if ($this->optionsResolved) { // @codeCoverageIgnoreStart return; // @codeCoverageIgnoreEnd } $this->optionsResolver->clear(); $this->optionsResolver->setRequired( array( 'page', 'language', 'country', 'slot', 'blockname', 'type', 'position', 'direction', ) ); $this->optionsResolver->resolve($options); $this->optionsResolved = true; }
php
{ "resource": "" }
q252782
UserService.editProfile
validation
public function editProfile($data) { /* @var $user UserInterface */ if (!($user = $this->hydrate($data, $this->getEditProfileForm()))) { return; } $eventManager = $this->getEventManager(); $eventManager->trigger(__FUNCTION__, $this, compact('user')); $this->getMapper()->update($user)->save(); $eventManager->trigger(__FUNCTION__ . '.post', $this, compact('user')); return $user; }
php
{ "resource": "" }
q252783
UserService.confirmEmail
validation
public function confirmEmail($token) { /* @var $user UserInterface */ $user = $this->getMapper()->findOneBy(['registrationToken' => $token]); if (!$user instanceof UserInterface) { return; } $eventManager = $this->getEventManager(); $eventManager->trigger(__METHOD__, $this, $user); $user->setRegistrationToken($this->getRegistrationToken()); $user->setEmailConfirmed(true); $this->getMapper()->update($user)->save(); $eventManager->trigger(__METHOD__ . '.post', $this, $user); return $user; }
php
{ "resource": "" }
q252784
UserService.changePassword
validation
public function changePassword($data) { /* @var $user UserInterface */ if (!($user = $this->hydrate($data, $this->getChangePasswordForm()))) { return; } $eventManager = $this->getEventManager(); $eventManager->trigger(__METHOD__, $this, $user); $password = $user->getPassword(); $passwordService = $this->getMapper()->getPasswordService(); $user->setPassword($passwordService->create($password)); $this->getMapper()->update($user)->save(); $eventManager->trigger(__METHOD__ . '.post', $this, $user); return $user; }
php
{ "resource": "" }
q252785
UserService.confirmPasswordReset
validation
public function confirmPasswordReset($token) { $user = $this->getMapper()->findOneBy(['registrationToken' => $token]); if (!$user instanceof UserInterface) { return; } $eventManager = $this->getEventManager(); $eventManager->trigger(__METHOD__, $this, $user); $user->setRegistrationToken($this->getRegistrationToken()); $user->setEmailConfirmed(true); $password = $this->getPasswordGenerator()->generate(); $passwordService = $this->getMapper()->getPasswordService(); $user->setPassword($passwordService->create($password)); $viewModel = new ViewModel(compact('user', 'password')); $viewModel->setTemplate('mail-message/user-change-password-success'); $mailService = $this->getMailService(); $message = $mailService->getMessage(); $message->setTo($user->getEmail(), $user->getDisplayName()); $subject = 'Your password has been changed!'; if ($this->getTranslator() && $this->isTranslatorEnabled()) { $subject = $this->getTranslator()->translate( $subject, $this->getTranslatorTextDomain() ); } $message->setSubject($subject); $mailService->setBody($viewModel)->sendMessage(); $this->getMapper()->update($user)->save(); $eventManager->trigger(__METHOD__ . '.post', $this, $user); return $user; }
php
{ "resource": "" }
q252786
UserService.changeEmail
validation
public function changeEmail($data) { /* @var $user UserInterface */ if (!($user = $this->hydrate($data, $this->getChangeEmailForm()))) { return; } $eventManager = $this->getEventManager(); $eventManager->trigger(__METHOD__, $this, $user); $user->setEmailConfirmed(false); $viewModel = new ViewModel(compact('user')); $viewModel->setTemplate('mail-message/user-confirm-email'); $mailService = $this->getMailService(); $message = $mailService->getMessage(); $message->setTo($user->getEmail(), $user->getDisplayName()); $subject = 'Please, confirm your email!'; if ($this->getTranslator() && $this->isTranslatorEnabled()) { $subject = $this->getTranslator()->translate( $subject, $this->getTranslatorTextDomain() ); } $message->setSubject($subject); $mailService->setBody($viewModel)->sendMessage(); $this->getMapper()->update($user)->save(); $eventManager->trigger(__METHOD__ . '.post', $this, $user); return $user; }
php
{ "resource": "" }
q252787
UserService.changeSecurityQuestion
validation
public function changeSecurityQuestion($data) { /* @var $user UserInterface */ if (!($user = $this->hydrate($data, $this->getChangeSecurityQuestionForm()))) { return; } $eventManager = $this->getEventManager(); $eventManager->trigger(__METHOD__, $this, $user); $this->getMapper()->update($user)->save(); $eventManager->trigger(__METHOD__ . '.post', $this, $user); return $user; }
php
{ "resource": "" }
q252788
Service.addGroup
validation
public function addGroup(Group $group) { $group->setService($this); $this->groups[$group->getName()] = $group; }
php
{ "resource": "" }
q252789
Service.getGroup
validation
public function getGroup($name) { if (array_key_exists($name, $this->groups)) { return $this->groups[$name]; } throw new KeyNotFoundInSetException($name, array_keys($this->groups), 'groups'); }
php
{ "resource": "" }
q252790
AuthenticateEvent.onExecuteAction
validation
public function onExecuteAction(ExecuteActionEvent $event){ $request=$event->getRequest(); $authenticate=$request->getConfig()->getObject('authenticate'); if($authenticate){ $this->execute($event,$authenticate); } }
php
{ "resource": "" }
q252791
Manager.preencherLista
validation
private function preencherLista($pagamentos) { $resultado = array(); foreach ($pagamentos as $pagamento) { $resultado[] = $pagamento->setAutenticacao($this->getAutenticacaoManager()->obterAutenticacaoBasica($pagamento->getAutenticacaoId())); } return $resultado; }
php
{ "resource": "" }
q252792
ConsignmentManager.saveConsignment
validation
public function saveConsignment(ConsignmentInterface $consignment) { $adapter = $this->getAdapter($consignment); $event = new EventConsignment($consignment); $this->eventDispatcher->dispatch(Events::PRE_CONSIGNMENT_SAVE, $event); if (! $consignment->getStatus()) { $consignment->setStatus(ConsignmentStatusList::STATUS_NEW); } try { $adapter->saveConsignment($consignment); $this->consignmentRepository->saveConsignment($consignment); } catch (\Exception $e) { throw new VendorAdapterException('Error during consignment saving.', null, $e); } $event = new EventConsignment($consignment); $this->eventDispatcher->dispatch(Events::POST_CONSIGNMENT_SAVE, $event); }
php
{ "resource": "" }
q252793
ConsignmentManager.removeConsignment
validation
public function removeConsignment(ConsignmentInterface $consignment) { $adapter = $this->getAdapter($consignment); $event = new EventConsignment($consignment); $this->eventDispatcher->dispatch(Events::PRE_CONSIGNMENT_REMOVE, $event); if ($consignment->getStatus() != ConsignmentStatusList::STATUS_NEW) { throw new OperationNotPermittedException( sprintf( 'Can not remove Consignment "%s" with status "%s"', $consignment->getId(), $consignment->getStatus() ) ); } try { $adapter->removeConsignment($consignment); $this->consignmentRepository->removeConsignment($consignment); } catch (\Exception $e) { throw new VendorAdapterException('Error during consignment removing.', null, $e); } $event = new EventConsignment($consignment); $this->eventDispatcher->dispatch(Events::POST_CONSIGNMENT_REMOVE, $event); }
php
{ "resource": "" }
q252794
ConsignmentManager.dispatch
validation
public function dispatch(DispatchConfirmationInterface $dispatchConfirmation) { try { $event = new EventDispatchConfirmation($dispatchConfirmation); $this->eventDispatcher->dispatch(Events::PRE_CONSIGNMENTS_DISPATCH, $event); $adapter = $this->getAdapter($dispatchConfirmation->getConsignments()->first()); $adapter->dispatch($dispatchConfirmation); $this->dispatchConfirmationRepository->saveDispatchConfirmation($dispatchConfirmation); foreach ($dispatchConfirmation->getConsignments() as $consignment) { $consignment->setDispatchConfirmation($dispatchConfirmation); $previousStatus = $consignment->getStatus(); /** @var ParcelInterface $parcel */ foreach ($consignment->getParcels() as $parcel) { $parcel->setStatus(ConsignmentStatusList::STATUS_DISPATCHED); } $consignment->setStatus(ConsignmentStatusList::STATUS_DISPATCHED); $this->consignmentRepository->saveConsignment($consignment); $this->dispatchOnConsignmentStatusChange($consignment, $previousStatus); } $event = new EventDispatchConfirmation($dispatchConfirmation); $this->eventDispatcher->dispatch(Events::POST_CONSIGNMENTS_DISPATCH, $event); } catch (\Exception $e) { throw new VendorAdapterException('Error during consignments dispatching.', null, $e); } }
php
{ "resource": "" }
q252795
ConsignmentManager.cancelConsignment
validation
public function cancelConsignment(ConsignmentInterface $consignment) { $adapter = $this->getAdapter($consignment); $event = new EventConsignment($consignment); $this->eventDispatcher->dispatch(Events::PRE_CONSIGNMENT_CANCEL, $event); try { $adapter->cancelConsignment($consignment); /** @var ParcelInterface $parcel */ foreach ($consignment->getParcels() as $parcel) { $parcel->setStatus(ConsignmentStatusList::STATUS_CANCELED); } $consignment->setStatus(ConsignmentStatusList::STATUS_CANCELED); $this->consignmentRepository->saveConsignment($consignment); } catch (\Exception $e) { throw new VendorAdapterException('Error during consignment cancel.', null, $e); } $event = new EventConsignment($consignment); $this->eventDispatcher->dispatch(Events::POST_CONSIGNMENT_CANCEL, $event); }
php
{ "resource": "" }
q252796
Aggregate.getBonusTotals
validation
private function getBonusTotals($dsBegin, $dsEnd) { $query = $this->qbGetBonusTotals->build(); $conn = $query->getConnection(); $bind = [ QBGetTotals::BND_PERIOD_BEGIN => $dsBegin, QBGetTotals::BND_PERIOD_END => $dsEnd ]; $rs = $conn->fetchAll($query, $bind); $result = []; foreach ($rs as $one) { $accId = $one[QBGetTotals::A_ACC_ID]; $custId = $one[QBGetTotals::A_CUST_ID]; $total = $one[QBGetTotals::A_TOTAL]; if ($custId) { $item = new DTotal(); $item->accountId = $accId; $item->customerId = $custId; $item->total = $total; $result[$custId] = $item; } } return $result; }
php
{ "resource": "" }
q252797
SettingsService.findParameter
validation
protected function findParameter($namespace, $name, $namespaceParameters) { foreach ($namespaceParameters as $namespaceParameter) { if ($namespaceParameter->getNamespace() === $namespace && $namespaceParameter->getName() === $name) { return $namespaceParameter; } } return null; }
php
{ "resource": "" }
q252798
SettingsService.detectNamespace
validation
protected function detectNamespace($settings) { foreach ($this->options->getNamespaces() as $namespaceOptions) { $namespaceEntityClass = $namespaceOptions->getEntityClass(); if ($settings instanceof $namespaceEntityClass) { return $namespaceOptions->getName(); } } throw new Exception\InvalidArgumentException('Unknown Settings namespace'); }
php
{ "resource": "" }
q252799
Cookie.save
validation
public function save() { $this->modifiedTime = new \DateTime('now'); self::set( $this->namespace, base64_encode(serialize($this->instance)), $this->modifiedTime->getTimestamp() + $this->lifetime, $this->path, $this->domain, $this->secure ); return $this; }
php
{ "resource": "" }