_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 ($met... | 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) {
... | 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(... | 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)
... | 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);
... | 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]... | 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 $... | 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-ra... | 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/... | 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_... | 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();
fore... | 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;
}
... | 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... | 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',
__(
'Exte... | 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->renderizat... | 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::FORM... | 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, $dat... | 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 <goke@cottacush.com>
*/
if (extension_loaded('newrelic')) {
... | 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' => 'erro... | 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' => ... | 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->mergeFlas... | 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) {
$fla... | 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;
}... | 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->midd... | 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($previousMi... | 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 :... | 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'])) {
... | 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['visibl... | 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):
... | 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 invali... | 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) {
... | 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);
... | 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,... | 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-... | 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)))));
$proc... | 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) {... | 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... | 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 =... | 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);
... | 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);
}
foreac... | 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 Oauth2ClientExc... | 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' => $th... | 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')... | 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($co... | 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 Oauth2Clien... | 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 Oauth2... | 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 = ArrayHelpe... | 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
"
);
... | 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 = $thi... | 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->getStat... | 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... | 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_s... | 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())... | 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 && $con... | 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->createFavi... | php | {
"resource": ""
} |
q247986 | RequestHandler.applyResponseEncoding | validation | private function applyResponseEncoding(
Request $request,
Response $response
)
{
$allowedCompressionAsString = $request
->headers
->get('Accept-Encoding');
if (!$allowedCompressionAsString) {
return;
}
$allowedCompression = ex... | 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,
... | 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... | 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(... | 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 ... | 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
... | 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[... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.