_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q247900 | ControllerDocumentation.getEndpoints | validation | protected function getEndpoints()
{
if (!$this->endpointsCache) {
$isHidden = $this->getControllerMethod('isMethodHidden');
$endpoints = [];
$parts = [];
$methods = $this->reflectedController->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method) {
if (preg_match('/([a-z]+)([A-Z]\w+)Endpoint$/', $method->getName(), $parts)) {
if (!$isHidden($method->getName())) {
$httpVerb = strtolower($parts[1]);
$endpoint = $this->camelcaseToHyphenated($parts[2]);
if (!array_key_exists($httpVerb, $endpoints)) {
$endpoints[$httpVerb] = array();
}
$endpoints[$httpVerb][$endpoint] = $this->documentation->getMethodDocumentation($method);
}
}
}
$this->endpointsCache = $endpoints;
}
return $this->endpointsCache;
} | php | {
"resource": ""
} |
q247901 | ControllerDocumentation.getControllers | validation | protected function getControllers()
{
if (!$this->controllersCache) {
$isHidden = $this->getControllerMethod('isMethodHidden');
$methods = $this->reflectedController->getMethods(\ReflectionMethod::IS_PUBLIC);
$controllers = [];
foreach ($methods as $method) {
if (preg_match('/(\w+)Controller$/', $method->getName(), $parts)) {
if (!$isHidden($method->getName())) {
$controllers[] = $this->camelcaseToHyphenated($parts[1]);
}
}
}
$this->controllersCache = $controllers;
}
return $this->controllersCache;
} | php | {
"resource": ""
} |
q247902 | ControllerDocumentation.getControllerMethod | validation | protected function getControllerMethod($methodName)
{
$reflectionMethod = $this->reflectedController->getMethod($methodName);
$reflectionMethod->setAccessible(true);
return function () use ($reflectionMethod) {
return $reflectionMethod->invokeArgs($this->controller, func_get_args());
};
} | php | {
"resource": ""
} |
q247903 | BaseHttpClient.get | validation | public function get($url, $params = [])
{
if (!is_array($params)) {
throw new HttpClientException(HttpClientErrorMessages::INVALID_QUERY_PARAMS);
}
$params = $this->filterParams($params);
$this->lastRequestParams = $params;
$this->lastRequestUrl = $this->buildUrl($url, $params);
return $this->curlAgent->get($this->lastRequestUrl, $this->rawResponse);
} | php | {
"resource": ""
} |
q247904 | BaseHttpClient.post | validation | public function post($url, $params)
{
if (is_array($params)) {
$params = $this->filterParams($params);
}
$this->lastRequestParams = $params;
$this->lastRequestUrl = $this->buildUrl($url);
return $this->curlAgent->setOption(CURLOPT_POSTFIELDS, $params)
->post($this->lastRequestUrl, $this->rawResponse);
} | php | {
"resource": ""
} |
q247905 | Profile.instantiate | validation | public function instantiate($profile, $provider)
{
$this->provider = $provider;
switch ($provider) {
case 'facebook':
$this->info = $this->parseFb($profile);
break;
case 'twitter':
$this->info = $this->parseTwt($profile);
break;
}
return $this;
} | php | {
"resource": ""
} |
q247906 | Profile.parseFb | validation | public function parseFb($raw_profile)
{
$profile = $raw_profile;
$profile->avatar = sprintf('http://graph.facebook.com/%s/picture', $profile->id);
return (array) $profile;
} | php | {
"resource": ""
} |
q247907 | Response.setBodyData | validation | public function setBodyData($data)
{
if (!$data instanceof \Generator) {
$this->body[static::DEFAULT_DATA_NAME] = $data;
return $this;
}
foreach ($data as $key => $value) {
$actualKey = $key ?: static::DEFAULT_DATA_NAME;
$this->body[$actualKey] = $value;
}
return $this;
} | php | {
"resource": ""
} |
q247908 | Response.prepareResponse | validation | public function prepareResponse()
{
if (!$this->writer) {
$this->writer = $this->writerFactory->getWriterFor(
$this->request->getFormats()
);
}
$this->preparedResponse = $this->writer->format($this->getBody(), $this->responseName);
return $this;
} | php | {
"resource": ""
} |
q247909 | Response.respond | validation | public function respond()
{
if (is_null($this->preparedResponse)) {
$this->prepareResponse();
}
if ($this->status instanceof Status) {
header($this->status->getHttpHeader());
}
header("Content-Type: {$this->writer->getContentType()}");
echo $this->preparedResponse;
return $this;
} | php | {
"resource": ""
} |
q247910 | Rating.set_movie_params | validation | public function set_movie_params() {
$post_id = get_the_ID();
$is_active = $this->get_rating_state( $post_id );
$options = $this->model->get_theme_options();
$params = [
'postID' => $post_id,
'dark' => $options['enable-dark'],
'imdb_button' => __( 'TOTAL', 'extensions-for-grifus-rating' ),
'is_active' => $is_active,
];
return $params;
} | php | {
"resource": ""
} |
q247911 | Rating.get_movie_rating | validation | public function get_movie_rating( $votes ) {
$votations = [];
foreach ( $votes as $key => $value ) {
for ( $i = 0; $i < $value; $i++ ) {
$votations[] = $key;
}
}
if ( count( $votations ) ) {
$rating = array_sum( $votations ) / count( $votations );
return round( $rating, 1 );
}
return 'N/A';
} | php | {
"resource": ""
} |
q247912 | Rating.restart_rating | validation | public function restart_rating( $post_id, $post, $update ) {
App::setCurrentID( 'EFG' );
if ( Module::CustomRatingGrifus()->getOption( 'restart-when-add' ) ) {
unset( $_POST['imdbRating'], $_POST['imdbVotes'] );
if ( App::main()->is_after_insert_post( $post, $update ) ) {
if ( ! $this->model->get_movie_votes( $post_id ) ) {
$votes = $this->get_default_votes( $post_id );
$this->set_rating_and_votes( $post_id, $votes );
return true;
}
}
}
return false;
} | php | {
"resource": ""
} |
q247913 | Rating.restart_all_ratings | validation | public function restart_all_ratings() {
$nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
if ( ! wp_verify_nonce( $nonce, 'eliasis' ) && ! wp_verify_nonce( $nonce, 'customRatingGrifusAdmin' ) ) {
die( 'Busted!' );
}
$response['ratings_restarted'] = 0;
$posts = $this->model->get_posts();
foreach ( $posts as $post ) {
if ( isset( $post->ID ) && ! $this->model->get_movie_votes( $post->ID ) ) {
$this->set_rating_and_votes(
$post->ID,
$this->get_default_votes( $post->ID )
);
$response['ratings_restarted']++;
}
}
echo json_encode( $response );
die();
} | php | {
"resource": ""
} |
q247914 | Rating.update_rating | validation | public function update_rating( $post_id, $post, $update ) {
App::setCurrentID( 'EFG' );
if ( App::main()->is_after_update_post( $post, $update ) ) {
if ( isset( $_POST['efg-update-rating'] ) ) {
for ( $i = 1; $i <= 10; $i++ ) {
if ( ! isset( $_POST[ "efg-rating-$i" ] ) ) {
return false;
}
$votes[ "$i" ] = (int) $_POST[ "efg-rating-$i" ];
}
$this->set_rating_and_votes( $post_id, $votes );
}
}
return true;
} | php | {
"resource": ""
} |
q247915 | Rating.restart_when_add | validation | public function restart_when_add() {
$state = isset( $_POST['state'] ) ? $_POST['state'] : null;
$nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
if ( ! wp_verify_nonce( $nonce, 'eliasis' ) && ! wp_verify_nonce( $nonce, 'customRatingGrifusAdmin' ) ) {
die( 'Busted!' );
}
App::setCurrentID( 'EFG' );
$slug = Module::CustomRatingGrifus()->getOption( 'slug' );
$this->model->set_restart_when_add( $slug, $state );
$response = [ 'restart-when-add' => $state ];
echo json_encode( $response );
die();
} | php | {
"resource": ""
} |
q247916 | Rating.add_meta_boxes | validation | public function add_meta_boxes( $post_type, $post ) {
App::setCurrentID( 'EFG' );
$is_active = $this->get_rating_state( $post->ID );
if ( App::main()->is_publish_post( $post ) && $is_active ) {
$this->add_styles();
$this->add_scripts();
add_meta_box(
'info_movie-rating-movie',
__(
'Extensions For Grifus - Custom rating',
'extensions-for-grifus-rating'
),
[ $this, 'render_meta_boxes' ],
$post_type,
'normal',
'high'
);
}
} | php | {
"resource": ""
} |
q247917 | Rating.render_meta_boxes | validation | public function render_meta_boxes( $post ) {
App::setCurrentID( 'EFG' );
wp_nonce_field( '_rating_movie_nonce', 'rating_movie_nonce' );
$meta_boxes = Module::CustomRatingGrifus()->getOption( 'path', 'meta-boxes' );
$data = [ 'votes' => $this->model->get_movie_votes( $post->ID ) ];
$this->view->renderizate( $meta_boxes, 'wp-insert-post', $data );
} | php | {
"resource": ""
} |
q247918 | DateUtils.toRelativeTime | validation | public static function toRelativeTime($fromTime, $toTime = 'now', $format = 'days')
{
$startTime = new DateTime($fromTime);
$endTime = new DateTime($toTime);
return $startTime->diff($endTime)->$format;
} | php | {
"resource": ""
} |
q247919 | DateUtils.getDateRangeText | validation | public static function getDateRangeText($startDate, $endDate, $toSeparator = 'to')
{
if ($startDate == $endDate) {
return self::format($startDate, DateFormat::FORMAT_SHORT);
} elseif (self::format($startDate, DateFormat::FORMAT_YEAR)
== self::format($endDate, DateFormat::FORMAT_YEAR)
) {
$start_date = (
self::format($startDate, DateFormat::FORMAT_MONTH)
== self::format($endDate, DateFormat::FORMAT_MONTH))
? self::format($startDate, DateFormat::FORMAT_DAY) :
self::format($startDate, DateFormat::FORMAT_SHORT_NO_YEAR);
} else {
$start_date = self::format($startDate, DateFormat::FORMAT_SHORT);
}
return $start_date . ' ' . $toSeparator . ' ' . self::format($endDate, DateFormat::FORMAT_SHORT);
} | php | {
"resource": ""
} |
q247920 | DateUtils.convertDate | validation | public static function convertDate($dateString, $fromFormat, $toFormat)
{
$date = DateTime::createFromFormat($fromFormat, $dateString);
if (!$date && $fromFormat == DateFormat::FORMAT_ORACLE_WITH_MICROSECONDS) {
$date = DateTime::createFromFormat(DateFormat::FORMAT_ORACLE_DATE_ONLY, $dateString);
}
if ($date) {
return $date->format($toFormat);
}
return $dateString;
} | php | {
"resource": ""
} |
q247921 | DateUtils.getDateTime | validation | public static function getDateTime($format, $timestamp = 'now')
{
$date = strtotime($timestamp);
if (!$date) {
return $timestamp;
}
return date($format, $date);
} | php | {
"resource": ""
} |
q247922 | BaseController.afterAction | validation | public function afterAction($action, $result)
{
$result = parent::afterAction($action, $result);
$this->setSecurityHeaders();
/**
* Set Current Transaction in New Relic
* @author Adegoke Obasa <[email protected]>
*/
if (extension_loaded('newrelic')) {
newrelic_name_transaction($action->controller->id . '/' . $action->id);
}
return $result;
} | php | {
"resource": ""
} |
q247923 | BaseController.setSecurityHeaders | validation | private function setSecurityHeaders()
{
$headers = Yii::$app->response->headers;
$headers->add('X-Frame-Options', 'DENY');
$headers->add('X-XSS-Protection', '1');
} | php | {
"resource": ""
} |
q247924 | BaseController.sendSuccessResponse | validation | public function sendSuccessResponse($data)
{
\Yii::$app->response->format = Response::FORMAT_JSON;
\Yii::$app->response->setStatusCode(200, $this->httpStatuses->getReasonPhrase(200));
return [
'status' => 'success',
'data' => $data
];
} | php | {
"resource": ""
} |
q247925 | BaseController.sendErrorResponse | validation | public function sendErrorResponse($message, $code, $httpStatusCode, $data = null)
{
\Yii::$app->response->format = Response::FORMAT_JSON;
\Yii::$app->response->setStatusCode($httpStatusCode, $this->httpStatuses->getReasonPhrase($httpStatusCode));
$response = [
'status' => 'error',
'message' => $message,
'code' => $code
];
if (!is_null($data)) {
$response["data"] = $data;
}
return $response;
} | php | {
"resource": ""
} |
q247926 | BaseController.sendFailResponse | validation | public function sendFailResponse($data, $httpStatusCode = 500)
{
\Yii::$app->response->format = Response::FORMAT_JSON;
\Yii::$app->response->setStatusCode($httpStatusCode, $this->httpStatuses->getReasonPhrase($httpStatusCode));
return [
'status' => 'fail',
'data' => $data
];
} | php | {
"resource": ""
} |
q247927 | BaseController.showFlashMessages | validation | public function showFlashMessages($sticky = false)
{
$timeout = $sticky ? 0 : 5000;
$flashMessages = [];
$allMessages = $this->getSession()->getAllFlashes();
foreach ($allMessages as $key => $message) {
if (is_array($message)) {
$message = $this->mergeFlashMessages($message);
}
$flashMessages[] = [
'message' => $message,
'type' => $key,
'timeout' => $timeout
];
}
$this->getSession()->removeAllFlashes();
return Html::script('var notifications =' . json_encode($flashMessages));
} | php | {
"resource": ""
} |
q247928 | BaseController.mergeFlashMessages | validation | protected function mergeFlashMessages($messageArray)
{
$messages = array_values($messageArray);
$flashMessage = '';
$flashMessageArr = [];
foreach ($messages as $message) {
if (is_array($message)) {
if (strlen($flashMessage) > 0) {
$flashMessage .= '<br/>';
}
$flashMessage .= $this->mergeFlashMessages($message);
} else {
$flashMessageArr[] = $message;
}
}
return $flashMessage . implode('<br/>', $flashMessageArr);
} | php | {
"resource": ""
} |
q247929 | BaseController.isPostCheck | validation | public function isPostCheck($redirectUrl = null)
{
if ($this->getRequest()->isPost) {
return true;
}
if (is_null($redirectUrl)) {
return false;
}
$this->sendTerminalResponse($redirectUrl);
} | php | {
"resource": ""
} |
q247930 | BaseController.setSessionAndRedirect | validation | public function setSessionAndRedirect($key, $value, $redirectUrl)
{
$this->getSession()->set($key, $value);
return $this->redirect($redirectUrl);
} | php | {
"resource": ""
} |
q247931 | BaseController.canAccess | validation | public function canAccess($permissionKeys, $fullAccessKey, $errorMsg, $defaultUrl, $redirect = false)
{
if ($this->getUser()->isGuest) {
return $this->getUser()->loginRequired();
}
if ($this->getPermissionManager()->canAccess($fullAccessKey)) {
return true;
}
if (!is_array($permissionKeys)) {
$permissionKeys = [$permissionKeys];
}
foreach ($permissionKeys as $permissionKey) {
if ($this->getPermissionManager()->canAccess($permissionKey)) {
return true;
}
}
if ($redirect) {
$this->flashError($errorMsg);
$request = $this->getRequest();
$referrerUrl = $request->referrer;
$redirectUrl = ($referrerUrl == $request->url || is_null($referrerUrl)) ?
$defaultUrl : $referrerUrl;
$this->redirect($redirectUrl)->send();
Yii::$app->end(); //this enforces the redirect
}
return false;
} | php | {
"resource": ""
} |
q247932 | RouteCollector.addRoute | validation | public function addRoute($httpMethod, $route, $handler, array $middleware = [])
{
if (!$handler instanceof HandlerContainer) {
$handler = new HandlerContainer($handler, array_merge($this->middlewareStack, $middleware));
} else {
$handler->addMiddleware(array_merge($this->middlewareStack, $middleware));
}
$handler = serialize($handler);
$route = $this->currentGroupPrefix . $route;
$routeDatas = $this->routeParser->parse($route);
foreach ((array) $httpMethod as $method) {
foreach ($routeDatas as $routeData) {
$this->dataGenerator->addRoute($method, $routeData, $handler);
}
}
} | php | {
"resource": ""
} |
q247933 | RouteCollector.addGroup | validation | public function addGroup($prefix, array $middleware, callable $callback)
{
$previousMiddlewareStack = $this->middlewareStack;
$previousGroupPrefix = $this->currentGroupPrefix;
$this->currentGroupPrefix = $previousGroupPrefix . $prefix;
$this->middlewareStack = array_merge($previousMiddlewareStack, $middleware);
$callback($this);
$this->currentGroupPrefix = $previousGroupPrefix;
$this->middlewareStack = $previousMiddlewareStack;
} | php | {
"resource": ""
} |
q247934 | NavHelper.sort | validation | public static function sort($a, $b)
{
if (!isset($a['position'])) {
return 0;
}
if (!isset($b['position'])) {
return 0;
}
if ($a['position'] === $b['position']) {
return 0;
}
return ($a['position'] < $b['position']) ? -1 : 1;
} | php | {
"resource": ""
} |
q247935 | NavHelper.applyActive | validation | public static function applyActive(&$Nav)
{
if ($Nav) {
foreach ($Nav as &$one) {
if (isset($one['items'])) {
self::applyActive($one['items']);
}
if (!isset($one['active'])) {
if (is_array($one['url'])) {
$url = $one['url'][0];
$route = Yii::$app->requestedRoute;
$params = Yii::$app->request->getQueryParams();
if ($url === '/' && $route === Yii::$app->controller->module->id . '/dashboard/index') {
$one['active'] = true;
} else {
$url = $one['url'];
$urlExploded = explode('/', $url[0]);
$one['submenuTemplate'] = '';
foreach (self::$active as $activeAction) {
$urlExploded[count($urlExploded) - 1] = $activeAction;
$url[0] = implode('/', $urlExploded);
$one['items'][] =
[
'label' => $one['label'] . ' - ' . $activeAction,
'url' => $url,
'options' => [
'class' => 'hidden'
]
];
if ('/' . Yii::$app->request->getQueryParam('parentRoute') === trim($url[0])) {
$one['items'][] =
[
'label' => $one['label'] . ' - Sub List',
'url' => array_merge(['/' . $route], $params),
'options' => [
'class' => 'hidden'
]
];
}
}
}
}
}
}
}
} | php | {
"resource": ""
} |
q247936 | NavHelper.applyVisible | validation | public static function applyVisible(&$Nav)
{
if ($Nav) {
foreach ($Nav as &$one) {
if (!isset($one['visible'])) {
if (isset($one['permission'])) {
$authItemModel = Yii::createObject(AuthItem::class);
$one['visible'] = Yii::$app->user->can($authItemModel::SUPER_ADMIN) || Yii::$app->user->can($one['permission']);
} else {
if (is_array($one['url'])) {
$url = explode('/', trim($one['url'][0], '/'));
if (isset($url['0']) && isset($url['1'])) {
$one['visible'] = Yii::$app->user->can('Super admin') || Yii::$app->user->can($url[0] . '/' . $url[1]);
}
}
}
}
if (isset($one['items'])) {
self::applyVisible($one['items']);
}
}
}
} | php | {
"resource": ""
} |
q247937 | Controller.hideMethod | validation | protected function hideMethod($methodName)
{
if (!method_exists($this, $methodName)) {
throw new Exception(500, "The method '$methodName' does not exist in ".get_called_class());
}
$this->hiddenMethods[$methodName] = true;
return $this;
} | php | {
"resource": ""
} |
q247938 | Controller.isMethodHidden | validation | public function isMethodHidden($methodName)
{
if (!method_exists($this, $methodName)) {
throw new Exception(500, "The method '$methodName' does not exist in ".get_called_class());
}
return isset($this->hiddenMethods[$methodName]);
} | php | {
"resource": ""
} |
q247939 | Version.compareTo | validation | public function compareTo($version)
{
$major = $version->getMajor();
$minor = $version->getMinor();
$patch = $version->getPatch();
$pre = $version->getPreRelease();
$build = $version->getBuild();
switch (true) {
case ($this->major < $major):
return 1;
case ($this->major > $major):
return -1;
case ($this->minor > $minor):
return -1;
case ($this->minor < $minor):
return 1;
case ($this->patch > $patch):
return -1;
case ($this->patch < $patch):
return 1;
// @codeCoverageIgnoreStart
}
// @codeCoverageIgnoreEnd
if ($pre || $this->pre) {
if (empty($this->pre) && $pre) {
return -1;
}
if ($this->pre && empty($pre)) {
return 1;
}
if (0 !== ($weight = $this->precedence($this->pre, $pre))) {
return $weight;
}
}
if ($build || $this->build) {
if ((null === $this->build) && $build) {
return 1;
}
if ($this->build && (null === $build)) {
return -1;
}
return $this->precedence($this->build, $build);
}
return 0;
} | php | {
"resource": ""
} |
q247940 | Version.setBuild | validation | public function setBuild($build)
{
$this->build = array_values((array)$build);
array_walk(
$this->build,
function (&$v) {
if (preg_match('/^[0-9]+$/', $v)) {
$v = (int)$v;
}
}
);
} | php | {
"resource": ""
} |
q247941 | Version.setPreRelease | validation | public function setPreRelease($pre)
{
$this->pre = array_values((array)$pre);
array_walk(
$this->pre,
function (&$v) {
if (preg_match('/^[0-9]+$/', $v)) {
$v = (int)$v;
}
}
);
} | php | {
"resource": ""
} |
q247942 | Version.parseString | validation | protected function parseString($string)
{
$this->build = null;
$this->major = 0;
$this->minor = 0;
$this->patch = 0;
$this->pre = null;
if (false === static::isValid($string)) {
throw new InvalidArgumentException(sprintf('The version string "%s" is invalid.', $string));
}
if (false !== strpos($string, '+')) {
list($string, $build) = explode('+', $string);
$this->setBuild(explode('.', $build));
}
if (false !== strpos($string, '-')) {
list($string, $pre) = explode('-', $string);
$this->setPreRelease(explode('.', $pre));
}
$version = explode('.', $string);
$this->major = (int)$version[0];
if (isset($version[1])) {
$this->minor = (int)$version[1];
}
if (isset($version[2])) {
$this->patch = (int)$version[2];
}
} | php | {
"resource": ""
} |
q247943 | Version.precedence | validation | protected function precedence($a, $b)
{
if (count($a) > count($b)) {
$l = -1;
$r = 1;
$x = $a;
$y = $b;
} else {
$l = 1;
$r = -1;
$x = $b;
$y = $a;
}
foreach (array_keys($x) as $i) {
if (false === isset($y[$i])) {
return $l;
}
if ($x[$i] === $y[$i]) {
continue;
}
$xi = is_integer($x[$i]);
$yi = is_integer($y[$i]);
if ($xi && $yi) {
return ($x[$i] > $y[$i]) ? $l : $r;
} elseif ((false === $xi) && (false === $yi)) {
return (max($x[$i], $y[$i]) == $x[$i]) ? $l : $r;
} else {
return $xi ? $r : $l;
}
}
return 0;
} | php | {
"resource": ""
} |
q247944 | OAuthSignature.get | validation | public function get(OAuthConsumerInterface $consumer,
OAuthTokenInterface $token,
$httpverb,
$url,
$params = [])
{
uksort($params, 'strcmp');
$base_url = $this->baseURL($httpverb, $url, $params);
$key = $consumer->secret.'&'.$token->secret;
return base64_encode(hash_hmac('sha1', $base_url, $key, true));
} | php | {
"resource": ""
} |
q247945 | OAuthSignature.baseURL | validation | public function baseURL($httpverb, $url, $params)
{
uksort($params, 'strcmp');
return strtoupper($httpverb).'&'.
rawurlencode($url).'&'.
rawurlencode(http_build_query($params));
} | php | {
"resource": ""
} |
q247946 | WriterFactoryInjector.getWriterFactory | validation | public function getWriterFactory()
{
if (!$this->writerFactory) {
$xmlFormatter = new Xml();
$jsonFormatter = new Json();
$this->writerFactory = new WriterFactory([
// xml
'xml' => $xmlFormatter,
'text/xml' => $xmlFormatter,
'application/xml' => $xmlFormatter,
// json
'json' => $jsonFormatter,
'application/json' => $jsonFormatter,
]);
}
return $this->writerFactory;
} | php | {
"resource": ""
} |
q247947 | CheckboxListBehavior.beforeUpdate | validation | public function beforeUpdate($event)
{
if (is_array($this->fields)) {
foreach ($this->fields as $field) {
if (is_array($event->sender->{$field})) {
$event->sender->{$field} = implode(';', $event->sender->{$field});
}
}
}
} | php | {
"resource": ""
} |
q247948 | CheckboxListBehavior.afterFind | validation | public function afterFind($event)
{
if (is_array($this->fields)) {
foreach ($this->fields as $field) {
if ($event->sender->{$field}) {
$event->sender->{$field} = explode(';', $event->sender->{$field});
}
}
}
} | php | {
"resource": ""
} |
q247949 | Request.getReaderFactory | validation | protected function getReaderFactory()
{
if (!$this->readerFactory) {
$this->readerFactory = new ReaderFactory([
new Json(),
new Xml(),
]);
}
return $this->readerFactory;
} | php | {
"resource": ""
} |
q247950 | Request.useActualParameters | validation | protected function useActualParameters()
{
$this->setParameters($this->urlToParameters($this->getRequestedUri()));
$this->setParameters($_REQUEST);
$this->setParameters($this->parseHeader($_SERVER));
$this->setParameters($this->stringToArray($this->readBody()));
return $this->getParameters();
} | php | {
"resource": ""
} |
q247951 | Request.parseHeader | validation | protected function parseHeader(array $headers = [])
{
$processedHeaders = array();
foreach ($headers as $key => $value) {
if (substr($key, 0, 5) == 'HTTP_') {
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
$processedHeaders[$name] = $value;
} elseif ($key == 'CONTENT_TYPE') {
$processedHeaders['Content-Type'] = $value;
} elseif ($key == 'CONTENT_LENGTH') {
$processedHeaders['Content-Length'] = $value;
}
}
return $processedHeaders;
} | php | {
"resource": ""
} |
q247952 | Request.urlToParameters | validation | protected function urlToParameters($url)
{
$urlParameters = [];
$url = parse_url($url, PHP_URL_PATH);
$urlParts = explode('/', $url);
reset($urlParts); // Note, the first entry will always be blank
$key = next($urlParts);
while (($value = next($urlParts)) !== false) {
$urlParameters[$key] = $value;
$key = $value;
}
return $urlParameters;
} | php | {
"resource": ""
} |
q247953 | Request.stringToArray | validation | protected function stringToArray($string)
{
if (!$string || !is_string($string)) {
return [];
}
$result = $this->getReaderFactory()->read($string);
if ($result) {
return $result;
}
$array = [];
$array['text'] = $string;
return $array;
} | php | {
"resource": ""
} |
q247954 | Request.getParameter | validation | public function getParameter($key, $default = null)
{
// Request _should_ contain get, post and cookies
if (array_key_exists($key, $this->parameters)) {
return $this->parameters[$key];
}
// We can also flatten out the variable names to see if they exist
$flatKey = $this->flatten($key);
foreach ($this->parameters as $index => $value) {
if ($flatKey == $this->flatten($index)) {
return $value;
}
}
return $default;
} | php | {
"resource": ""
} |
q247955 | Request.getRequestChain | validation | public function getRequestChain()
{
if (is_null($this->requestChain)) {
$this->requestChain = $this->getRequestChainFromUri($this->requestedUri);
}
return $this->requestChain;
} | php | {
"resource": ""
} |
q247956 | Request.getFormatFromUri | validation | protected function getFormatFromUri($requestedUri)
{
$uriParts = explode('?', $requestedUri, 2);
$uriWithoutGet = reset($uriParts);
$uriAndFormat = explode('.', $uriWithoutGet);
if (count($uriAndFormat) >= 2) {
return end($uriAndFormat);
}
return null;
} | php | {
"resource": ""
} |
q247957 | Request.getRequestChainFromUri | validation | protected function getRequestChainFromUri($requestedUri)
{
// Trim any get variables and the requested format, eg: /requested/uri.format?get=variables
$requestedUri = preg_replace('/[\?\.].*$/', '', $requestedUri);
// Clear the base url
$requestChain = explode('/', $requestedUri);
if (!$requestChain[0]) {
unset($requestChain[0]);
}
return array_values($requestChain);
} | php | {
"resource": ""
} |
q247958 | Request.setParameters | validation | protected function setParameters($newParameters)
{
if (is_scalar($newParameters)) {
if (!is_string($newParameters)) {
throw new \Exception('newParameters can not be scalar');
}
$newParameters = $this->stringToArray($newParameters);
}
foreach ($newParameters as $field => $value) {
$this->setParameter($field, $value);
}
return $this;
} | php | {
"resource": ""
} |
q247959 | Request.setParameter | validation | protected function setParameter($name, $value)
{
if (!is_scalar($name)) {
throw new \Exception('Parameter name must be scalar');
}
$this->parameters[$name] = $value;
return $this;
} | php | {
"resource": ""
} |
q247960 | Oauth2Client.handleAuthorizeResponse | validation | private function handleAuthorizeResponse($response)
{
$status = ArrayHelper::getValue($response, 'status');
if (!is_null($status) && $status == 'success') {
$code = ArrayHelper::getValue($response, 'data.code');
if (is_null($code)) {
throw new Oauth2ClientException(self::CODE_NOT_SET);
}
return $code;
} else {
$message = ArrayHelper::getValue($response, 'message', self::DEFAULT_ERROR);
throw new Oauth2ClientException($message);
}
} | php | {
"resource": ""
} |
q247961 | Oauth2Client.authorize | validation | public function authorize()
{
$this->validateAuthParams();
try {
$response = $this->curl->setOption(
CURLOPT_POSTFIELDS,
http_build_query(array(
'grant_type' => self::GRANT_TYPE_AUTHORIZATION_CODE,
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
'response_type' => self::RESPONSE_TYPE_CODE,
'state' => self::STATE_ALIVE
))
)->post($this->authUrl, false);
} catch (InvalidParamException $invalidParamException) {
throw new Oauth2ClientException($invalidParamException->getMessage());
}
return $this->handleAuthorizeResponse($response);
} | php | {
"resource": ""
} |
q247962 | Oauth2Client.handleTokenResponse | validation | private function handleTokenResponse($response)
{
$params = ($response instanceof OAuthToken) ? $response->getParams() : $response;
$status = ArrayHelper::getValue($params, 'status');
if (!is_null($status) && $status == 'success') {
$token = ArrayHelper::getValue($params, 'data');
if (is_null($token)) {
throw new Oauth2ClientException(self::CODE_NOT_SET);
}
return $token;
} else {
$message = ArrayHelper::getValue($params, 'message', self::DEFAULT_ERROR);
throw new Oauth2ClientException($message);
}
} | php | {
"resource": ""
} |
q247963 | Oauth2Client.fetchAccessToken | validation | public function fetchAccessToken($code)
{
$this->validateTokenParams();
$this->oauth2->tokenUrl = $this->tokenUrl;
$this->oauth2->clientId = $this->clientId;
$this->oauth2->clientSecret = $this->clientSecret;
try {
$response = $this->oauth2->fetchAccessToken($code);
} catch (Exception $ex) {
throw new Oauth2ClientException($ex->getMessage());
}
return $this->handleTokenResponse($response);
} | php | {
"resource": ""
} |
q247964 | Oauth2Client.validateAuthParams | validation | protected function validateAuthParams()
{
if (empty($this->authUrl) || filter_var($this->authUrl, FILTER_VALIDATE_URL) === false) {
throw new Oauth2ClientException(sprintf(self::INVALID_AUTH_URL, $this->authUrl));
}
if (empty($this->clientId)) {
throw new Oauth2ClientException(self::INVALID_CLIENT_ID);
}
if (empty($this->clientSecret)) {
throw new Oauth2ClientException(self::INVALID_CLIENT_SECRET);
}
return true;
} | php | {
"resource": ""
} |
q247965 | Oauth2Client.validateTokenParams | validation | protected function validateTokenParams()
{
if (empty($this->tokenUrl) || filter_var($this->tokenUrl, FILTER_VALIDATE_URL) === false) {
throw new Oauth2ClientException(sprintf(self::INVALID_TOKEN_URL, $this->tokenUrl));
}
if (empty($this->clientId)) {
throw new Oauth2ClientException(self::INVALID_CLIENT_ID);
}
if (empty($this->clientSecret)) {
throw new Oauth2ClientException(self::INVALID_CLIENT_SECRET);
}
return true;
} | php | {
"resource": ""
} |
q247966 | Oauth2Client.getAccessToken | validation | public static function getAccessToken()
{
$oauthClientParams = ArrayHelper::getValue(\Yii::$app->params, 'oauth');
$oauthClient = new Oauth2Client($oauthClientParams);
$code = $oauthClient->authorize();
$token = $oauthClient->fetchAccessToken($code);
$accessToken = ArrayHelper::getValue($token, 'access_token');
return $accessToken;
} | php | {
"resource": ""
} |
q247967 | Rating.get_movie_votes | validation | public function get_movie_votes( $post_id ) {
$votes = get_post_meta( $post_id, 'imdbTotalVotes', true );
if ( ! empty( $votes ) ) {
return json_decode( $votes, true );
}
return false;
} | php | {
"resource": ""
} |
q247968 | Rating.set_movie_votes | validation | public function set_movie_votes( $post_id, $total_votes ) {
$total_votes = $total_votes ?: 'N/B';
if ( ! add_post_meta( $post_id, 'imdbVotes', $total_votes, true ) ) {
update_post_meta( $post_id, 'imdbVotes', $total_votes );
}
} | php | {
"resource": ""
} |
q247969 | Rating.set_total_votes | validation | public function set_total_votes( $post_id, $votes ) {
$votes = json_encode( $votes, true );
if ( ! add_post_meta( $post_id, 'imdbTotalVotes', $votes, true ) ) {
update_post_meta( $post_id, 'imdbTotalVotes', $votes );
}
} | php | {
"resource": ""
} |
q247970 | Rating.set_movie_rating | validation | public function set_movie_rating( $post_id, $rating ) {
if ( ! add_post_meta( $post_id, 'imdbRating', $rating, true ) ) {
update_post_meta( $post_id, 'imdbRating', $rating );
}
} | php | {
"resource": ""
} |
q247971 | Rating.set_user_vote | validation | public function set_user_vote( $post_id, $votes, $vote, $ip ) {
global $wpdb;
$table_name = $wpdb->prefix . 'efg_custom_rating';
$result = $wpdb->get_row(
"
SELECT id, vote
FROM $table_name
WHERE ip = '$ip'
AND post_id = $post_id
"
);
if ( ! isset( $result->id ) && ! isset( $result->vote ) ) {
$wpdb->insert(
$table_name,
[
'post_id' => $post_id,
'ip' => $ip,
'vote' => $vote,
],
[ '%d', '%s', '%d' ]
);
$votes[ $vote ]++;
} else {
if ( $result->vote != $vote ) {
$wpdb->update(
$table_name,
[
'post_id' => $post_id,
'ip' => $ip,
'vote' => $vote,
],
[ 'id' => $result->id ],
[ '%d', '%s', '%d' ],
[ '%d' ]
);
$votes[ $result->vote ]--;
$votes[ $vote ]++;
}
}
return $votes;
} | php | {
"resource": ""
} |
q247972 | Rating.get_posts | validation | public function get_posts() {
$total_posts = wp_count_posts();
$total_posts = isset( $total_posts->publish ) ? $total_posts->publish : 0;
return get_posts(
[
'post_type' => 'post',
'numberposts' => $total_posts,
'post_status' => 'publish',
]
);
} | php | {
"resource": ""
} |
q247973 | BaseAction.processMessage | validation | protected function processMessage(&$message)
{
if (!$message instanceof \Closure) {
return;
}
$callback = $message;
$message = $callback($this->model);
} | php | {
"resource": ""
} |
q247974 | Router.run | validation | public function run(Request $request)
{
$this->stopwatch = microtime(true);
$starttime = $request->server->get('REQUEST_TIME_FLOAT');
$this->log("Router: ->run() called. Starting clock at REQUEST_TIME+%.2fms", microtime(true) - $starttime);
try {
$response = $this->process($request);
} catch (\Throwable $e) {
$this->log("Router: Exception");
$response = $this->handleException($e, $request);
}
$this->log("Router: Preparing to send response");
$response->prepare($request);
$response->send();
$this->log("Router: Response sent");
} | php | {
"resource": ""
} |
q247975 | Router.handleException | validation | protected function handleException(\Throwable $e, Request $request) : Response
{
// Wrap non HTTP exception/errors
if (!$e instanceof Exception\Exception) {
$e = new Exception\UncaughtException($e);
}
// Throw to an appropriate handler
$code = $e->getStatusCode();
if ($this->exceptionHandlers[$code] instanceof ExceptionHandler) {
return $this->exceptionHandlers[$code]->handle($e, $request);
} elseif ($this->defaultExceptionHandler instanceof ExceptionHandler) {
return $this->defaultExceptionHandler->handle($e, $request);
} else {
return (new \Circuit\ExceptionHandler\DefaultHandler)->handle($e, $request);
}
} | php | {
"resource": ""
} |
q247976 | Router.getMiddleware | validation | public function getMiddleware($name) : Middleware
{
if (!array_key_exists($name, $this->namedMiddleware)) {
throw new \UnexpectedValueException("No middleware registered under name '{$name}'");
}
return $this->namedMiddleware[$name];
} | php | {
"resource": ""
} |
q247977 | ProvidersManager.instantiate | validation | public function instantiate($provider)
{
if (!$this->supported($provider)) {
throw new ProviderNotSupportedException($provider);
}
$class = $this->providerClass($provider);
switch ($provider) {
case 'facebook':
return new $class($this->config,
$this->redirector,
$this->http,
$this->store,
$this->profile,
$this->access_token);
break;
case 'twitter':
return new $class($this->config,
$this->http,
$this->redirector,
$this->store,
$this->profile,
$this->signature,
$this->consumer,
$this->token,
$this->oauth);
break;
}
} | php | {
"resource": ""
} |
q247978 | Launcher.uninstallation | validation | public function uninstallation() {
$this->model->delete_post_meta();
$this->model->delete_options();
$this->model->remove_tables();
} | php | {
"resource": ""
} |
q247979 | Launcher.run_ajax | validation | public function run_ajax() {
$methods = [ 'add_movie_rating' ];
foreach ( $methods as $method ) {
add_action( 'wp_ajax_' . $method, [ $this->rating, $method ] );
add_action( 'wp_ajax_nopriv_' . $method, [ $this->rating, $method ] );
}
} | php | {
"resource": ""
} |
q247980 | Launcher.set_options | validation | public function set_options() {
$slug = Module::CustomRatingGrifus()->getOption( 'slug' );
$options = $this->model->get_options();
foreach ( $options as $option => $value ) {
Module::CustomRatingGrifus()->setOption( $option, $value );
}
} | php | {
"resource": ""
} |
q247981 | Launcher.front | validation | public function front() {
add_action(
'wp', function() {
App::setCurrentID( 'EFG' );
if ( App::main()->is_single() && ! is_preview() ) {
$this->add_scripts( 'customRatingGrifus' );
$this->add_styles();
} elseif ( is_home() || is_category() || is_archive() || is_search() ) {
$this->add_scripts( 'customRatingGrifusHome' );
}
}
);
} | php | {
"resource": ""
} |
q247982 | Proxy.to | validation | public function to($target)
{
if (is_null($this->request)) {
throw new \LogicException('Missing request instance.');
}
$target = new Uri($target);
// Overwrite target scheme and host.
$uri = $this->request->getUri()
->withScheme($target->getScheme())
->withHost($target->getHost());
// Check for custom port.
if ($port = $target->getPort()) {
$uri = $uri->withPort($port);
}
// Check for subdirectory.
if ($path = $target->getPath()) {
$uri = $uri->withPath(rtrim($path, '/') . '/' . ltrim($uri->getPath(), '/'));
}
if (!empty($this->request->getQueryParams())) {
// special case for rql
$queryParams = $this->request->getQueryParams();
if (count($queryParams) == 1 && empty(array_shift($queryParams))) {
$queryKeys = array_keys($this->request->getQueryParams());
$uri = $uri->withQuery($queryKeys[0]);
} else {
$uri = $uri->withQuery(http_build_query($this->request->getQueryParams()));
}
}
$request = $this->request->withUri($uri);
// make sure we don't send empty headers
foreach ($request->getHeaders() as $headerName => $headerValue) {
if (empty($headerValue[0])) {
$request = $request->withoutHeader($headerName);
}
}
return $this->client->send($request);
} | php | {
"resource": ""
} |
q247983 | AbstractParamConverter.apply | validation | public function apply(Request $request, ParamConverter $configuration)
{
$param = $this->getRequestAttributeName($request, $configuration);
if (!$request->attributes->has($param)) {
return false;
}
$value = $request->attributes->get($param);
if (!$value && $configuration->isOptional()) {
return false;
}
$convertedValue = $this->convertValue($value, $configuration);
if (null === $convertedValue && false === $configuration->isOptional()) {
throw new NotFoundHttpException(
"Unable to find '{$configuration->getClass()}' with identifier '{$value}' not found"
);
}
$request->attributes->set($configuration->getName(), $convertedValue);
return true;
} | php | {
"resource": ""
} |
q247984 | AbstractParamConverter.supports | validation | public function supports(ParamConverter $configuration)
{
return $configuration->getClass() && is_a($configuration->getClass(), $this->getClass(), true);
} | php | {
"resource": ""
} |
q247985 | RequestHandler.handleServerRequest | validation | public function handleServerRequest(ServerRequestInterface $request): array
{
$messages = [];
try {
$body = $request->getBody()->getContents();
$uriPath = $request->getUri()->getPath();
if ('/favicon.ico' === $uriPath) {
return [$this->createFaviconResponse(), []];
}
$from = microtime(true);
$method = $request->getMethod();
$headers = $request->getHeaders();
$symfonyRequest = new Request(
$request->getQueryParams(),
$request->getParsedBody() ?? [],
$request->getAttributes(),
$request->getCookieParams(),
$request->getUploadedFiles(),
[], // Server is partially filled a few lines below
$body
);
$symfonyRequest->setMethod($method);
$symfonyRequest->headers->replace($headers);
$symfonyRequest->server->set('REQUEST_URI', $uriPath);
if (isset($headers['Host'])) {
$symfonyRequest->server->set('SERVER_NAME', explode(':', $headers['Host'][0]));
}
$symfonyResponse = $this->kernel->handle($symfonyRequest);
$this->kernel->terminate($symfonyRequest, $symfonyResponse);
$to = microtime(true);
$messages[] = new ConsoleMessage(
$request->getUri()->getPath(),
$method,
$symfonyResponse->getStatusCode(),
$symfonyResponse->getContent(),
\intval(($to - $from) * 1000)
);
$this->applyResponseEncoding(
$symfonyRequest,
$symfonyResponse
);
$httpResponse = new \React\Http\Response(
$symfonyResponse->getStatusCode(),
$symfonyResponse->headers->all(),
$symfonyResponse->getContent()
);
$symfonyRequest = null;
$symfonyResponse = null;
/*
* Catching errors and sending to syslog.
*/
} catch (\Throwable $exception) {
$messages[] = new ConsoleException($exception);
$httpResponse = new \React\Http\Response(
400,
['Content-Type' => 'text/plain'],
$exception->getMessage()
);
}
return [$httpResponse, $messages];
} | php | {
"resource": ""
} |
q247986 | RequestHandler.applyResponseEncoding | validation | private function applyResponseEncoding(
Request $request,
Response $response
)
{
$allowedCompressionAsString = $request
->headers
->get('Accept-Encoding');
if (!$allowedCompressionAsString) {
return;
}
$allowedCompression = explode(',', $allowedCompressionAsString);
$allowedCompression = array_map('trim', $allowedCompression);
if (in_array('gzip', $allowedCompression)) {
$response->setContent(gzencode($response->getContent()));
$response
->headers
->set('Content-Encoding', 'gzip');
return;
}
if (in_array('deflate', $allowedCompression)) {
$response->setContent(gzdeflate($response->getContent()));
$response
->headers
->set('Content-Encoding', 'deflate');
return;
}
} | php | {
"resource": ""
} |
q247987 | TranslatorDecorator.getCatalogue | validation | public function getCatalogue($locale = null)
{
if ($this->translator instanceof TranslatorBagInterface) {
return $this->translator->getCatalogue($locale);
}
return null;
} | php | {
"resource": ""
} |
q247988 | Bridge.bootstrap | validation | public function bootstrap($appBootstrap, $appenv, $debug)
{
$bootstrap = (new $appBootstrap());
$bootstrap->initialize($appenv, $debug);
$kernel = $bootstrap->getApplication();
$this->requestHandler = new RequestHandler($kernel);
} | php | {
"resource": ""
} |
q247989 | Bridge.handle | validation | public function handle(ServerRequestInterface $request)
{
list($httpResponse, $_) = $this
->requestHandler
->handleServerRequest($request);
return $httpResponse;
} | php | {
"resource": ""
} |
q247990 | Transformer.transformCollection | validation | public function transformCollection($collection)
{
if(is_object($collection))
$collection = $collection->toArray()["data"];
return array_map([$this , "transform"], $collection);
} | php | {
"resource": ""
} |
q247991 | Transformable.getTransformer | validation | public function getTransformer()
{
if (!property_exists($this , 'transformer') || !$this->transformer )
{
if(!$this->_defaultTransformer )
{
$this->createQualifiedTransformerClass();
}
return $this->_defaultTransformer;
}
return $this->transformer;
} | php | {
"resource": ""
} |
q247992 | Transformable.createQualifiedTransformerClass | validation | private function createQualifiedTransformerClass()
{
$reflection = new ReflectionClass( __CLASS__ );
$name = $reflection->getName();
$qualifiedTransformerClass = $name . "Transformer";
$this->setTransformer( $qualifiedTransformerClass );
} | php | {
"resource": ""
} |
q247993 | Logging.getCallable | validation | public static function getCallable(Logger $logger, $type, $maxMessageLength)
{
return function (MessageInterface $message) use ($logger, $type, $maxMessageLength) {
$startMessage = null;
if ($message instanceof RequestInterface) {
$startMessage = sprintf(
'Proxy %s start: HTTP/%s %s %s',
$type,
$message->getProtocolVersion(),
$message->getMethod(),
$message->getRequestTarget()
);
} elseif ($message instanceof ResponseInterface) {
$startMessage = sprintf(
'Proxy %s start: HTTP/%s %s %s',
$type,
$message->getProtocolVersion(),
$message->getStatusCode(),
$message->getReasonPhrase()
);
}
if (!is_null($startMessage)) {
$logger->log(Logger::INFO, $startMessage);
}
// output headers
foreach ($message->getHeaders() as $name => $value) {
$logger->log(
Logger::INFO,
sprintf(
"Proxy %s header: %s => %s",
$type,
$name,
implode(', ', $value)
)
);
}
$body = $message->getBody();
if (strlen($body) > $maxMessageLength) {
$body = substr($body, 0, $maxMessageLength).'[TRUNCATED]';
}
$logger->log(
Logger::INFO,
sprintf(
"Proxy %s body: %s",
$type,
$body
)
);
if (!is_null($message) && $message->getBody()->isSeekable()) {
$message->getBody()->rewind();
}
return $message;
};
} | php | {
"resource": ""
} |
q247994 | ComposerHook.installWebServer | validation | public static function installWebServer()
{
$appPath = __DIR__.'/../../../..';
self::createFolderIfNotExists("$appPath/web");
self::createCopy(
__DIR__,
'app.php',
"$appPath/web",
'app.php'
);
self::createCopy(
__DIR__,
'app_dev.php',
"$appPath/web",
'app_dev.php'
);
} | php | {
"resource": ""
} |
q247995 | ComposerHook.createFolderIfNotExists | validation | private static function createFolderIfNotExists(string $path)
{
if (false === @mkdir($path, 0777, true) && !is_dir($path)) {
throw new \RuntimeException(sprintf("Unable to create the %s directory\n", $path));
}
} | php | {
"resource": ""
} |
q247996 | ComposerHook.createCopy | validation | private static function createCopy(
string $from,
string $fromFilename,
string $to,
string $toFilename
) {
if (file_exists("$to/$toFilename")) {
unlink("$to/$toFilename");
}
copy(
realpath($from)."/$fromFilename",
realpath($to)."/$toFilename"
);
echo '> * Copy origin - '.realpath($from)."/$toFilename".PHP_EOL;
echo '> * Copy destination - '.realpath($to)."/$toFilename".PHP_EOL;
} | php | {
"resource": ""
} |
q247997 | AppFactory.createApp | validation | public static function createApp(
string $appPath,
string $environment,
bool $debug
): BaseKernel {
$envPath = $appPath.'/.env';
if (file_exists($envPath)) {
$dotenv = new Dotenv();
$dotenv->load($envPath);
}
$oneBundleAppConfig = new \OneBundleApp\App\OneBundleAppConfig($appPath, $environment);
\Symfony\Component\Debug\ErrorHandler::register();
\Symfony\Component\Debug\ExceptionHandler::register();
return new \Mmoreram\BaseBundle\Kernel\BaseKernel(
$oneBundleAppConfig->getBundles(),
$oneBundleAppConfig->getConfig(),
$oneBundleAppConfig->getRoutes(),
$environment,
$debug,
$appPath.'/var'
);
} | php | {
"resource": ""
} |
q247998 | NestedPropertyDenormalizer.supportsDenormalization | validation | public function supportsDenormalization($data, $type, $format = null)
{
if (!\class_exists($type)) {
return false;
}
$classAnnotation = $this->annotationReader->getClassAnnotation(
new \ReflectionClass($type),
NestedPropertyDenormalizerAnnotation::class
);
return $classAnnotation instanceof NestedPropertyDenormalizerAnnotation;
} | php | {
"resource": ""
} |
q247999 | ConsoleMessage.messageInMessage | validation | private function messageInMessage(string $message): string
{
$decodedMessage = json_decode($message, true);
if (
is_array($decodedMessage) &&
isset($decodedMessage['message']) &&
is_string($decodedMessage['message'])
) {
return $decodedMessage['message'];
}
return $message;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.