*/
protected function throwCurlException($curlErrorNumber, $message)
{
switch ($curlErrorNumber) {
case 6:
throw new CouldNotResolveHostException($message);
case 7:
throw new CouldNotConnectToHost($message);
case 28:
throw new OperationTimeoutException($message);
// an exception is thrown. This prevents any partial views from leaking.
try
{
include $__path;
}
catch (\Exception $e)
{
$this->handleViewException($e, $obLevel);
}
*/
protected function throwCurlException($curlErrorNumber, $message)
{
switch ($curlErrorNumber) {
case 6:
throw new CouldNotResolveHostException($message);
case 7:
throw new CouldNotConnectToHost($message);
case 28:
throw new OperationTimeoutException($message);
/**
* @param CurlException $exception\
*/
private function processCurlError(CurlException $exception)
{
$error = 'Curl error: ' . $exception->getMessage();
$this->log->error($error);
$this->throwCurlException($exception->getErrorNo(), $exception->getError());
}
} catch (ServerErrorResponseException $exception) {
$this->process5xxError($request, $exception, $body);
} catch (ClientErrorResponseException $exception) {
$this->process4xxError($request, $exception, $body);
} catch (CurlException $exception) {
$this->processCurlError($exception);
} catch (\Exception $exception) {
public function performRequest($method, $uri, $params = null, $body = null, $options = array())
{
$uri = $this->getURI($uri, $params);
$options += $this->connectionOpts;
$request = $this->buildGuzzleRequest($method, $uri, $body, $options);
$response = $this->sendRequest($request, $body);
return array(
}
$response = $connection->performRequest(
$method,
$uri,
$params,
$body
);
$connection->markAlive();
try {
$result = $this->transport->performRequest(
$this->getMethod(),
$this->getURI(),
$this->params,
$this->getBody()
);
} catch (\Exception $exception) {
$code = $exception->getCode();
/** @var \Elasticsearch\Endpoints\Get $endpoint */
$endpoint = $endpointBuilder('Get');
$endpoint->setID($id)
->setIndex($index)
->setType($type);
$endpoint->setParams($params);
$response = $endpoint->performRequest();
return $response['data'];
}
public function delete($id)
{
try {
$this->getClient()->get(array(
'index' => $this->name,
'type' => static::$default_type,
'id' => $id,
));
} catch (\Elasticsearch\Common\Exceptions\Missing404Exception $e) {
return false;
* @param array $fields
* @param array $parameters
*
* @return bool
*/
public function insert($id, array $fields, array $parameters = array())
{
$this->delete($id);
$fields['_parameters'] = base64_encode(json_encode($parameters));
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, array $parameters)
{
return call_user_func_array(array($this->index(), $method), $parameters);
}
}
case 0:
return $instance->$method();
case 1:
return $instance->$method($args[0]);
case 2:
return $instance->$method($args[0], $args[1]);
case 3:
case 0:
return $instance->$method();
case 1:
return $instance->$method($args[0]);
case 2:
return $instance->$method($args[0], $args[1]);
case 3:
'source_url' => $this->source_url,
'source_date' => (string) $this->source_date ?: time(),
'status' => $this->status,
'hits' => $this->hits,
'comments_number' => $this->comments_number,
'similar' => $this->similar,
'created_at' => (string) $this->created_at,
));
}
'source_url' => $this->source_url,
'source_date' => (string) $this->source_date ?: time(),
'status' => $this->status,
'hits' => $this->hits,
'comments_number' => $this->comments_number,
'similar' => $this->similar,
'created_at' => (string) $this->created_at,
));
}
static::creating(function ($post) {
//@todo вынести в модель парсераи там проверять существования scrapy
$user = Sentry::getUser() ?: \User::where('email', '=', 'greenx@mail.ru')->first()->id;
$post->user_id = $user;
});
static::saved(function ($post) {
$post->addIndex();
\Cache::tags('post-list', 'sidebar')->flush();
});
// payload to each of them so that they receive each of these arguments.
if ( ! is_array($payload)) $payload = array($payload);
$this->firing[] = $event;
foreach ($this->getListeners($event) as $listener)
{
$response = call_user_func_array($listener, $payload);
// If a response is returned from the listener and event halting is enabled
// We will append the names of the class to the event to distinguish it from
// other model events that are fired, allowing us to listen on each model
// event set individually instead of catching event for all the models.
$event = "eloquent.{$event}: ".get_class($this);
$method = $halt ? 'until' : 'fire';
return static::$dispatcher->$method($event, $this);
}
* Finish processing on a successful save operation.
*
* @param array $options
* @return void
*/
protected function finishSave(array $options)
{
$this->fireModelEvent('saved', false);
$this->syncOriginal();
// ID attribute on the model to the value of the newly inserted row's ID
// which is typically an auto-increment value managed by the database.
else
{
$saved = $this->performInsert($query, $options);
}
if ($saved) $this->finishSave($options);
return $saved;
* если пучтой то создает его
* @return mixed
* TODO сделать конфигурируемым по шаблону
*/
public function getMetaTitle() {
if (empty($this->page_title)) {
$this->page_title = $this->title;
$this->save();
}
return $this->page_title;
<?php $__env->startSection('title'); ?><?php echo e($post->getMetaTitle()); ?><?php $__env->stopSection(); ?>
<?php $__env->startSection('meta_description'); ?><?php echo e($post->getMetaDescription()); ?><?php $__env->stopSection(); ?>
<?php $__env->startSection('meta_keywords'); ?><?php echo e($post->meta_keywords); ?><?php $__env->stopSection(); ?><?php $__env->startSection('sidebar'); ?><?php $viewArgs = get_defined_vars(); echo Flatten\Facades\FlattenExtend::section('sidebar', function() use ($viewArgs) { extract($viewArgs); ?>
<?php echo $__env->make('pages/partials.sidebar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php }); ?><?php $__env->stopSection(); ?><?php $__env->startSection('content'); ?>
<?php echo $__env->make('posts/partials.details', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.default', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
extract($__data);
// We'll evaluate the contents of the view inside a try/catch block so we can
// flush out any stray output that might get out before an error occurs or
// an exception is thrown. This prevents any partial views from leaking.
try
{
include $__path;
}
catch (\Exception $e)
}
$compiled = $this->compiler->getCompiledPath($path);
// Once we have the path to the compiled file, we will evaluate the paths with
// typical PHP just like any other templates. We also keep a stack of views
// which have been rendered for right exception messages to be generated.
$results = $this->evaluatePath($compiled, $data);
array_pop($this->lastCompiled);
/**
* Get the evaluated contents of the view.
*
* @return string
*/
protected function getContents()
{
return $this->engine->get($this->path, $this->gatherData());
}
// We will keep track of the amount of views being rendered so we can flush
// the section after the complete rendering operation is done. This will
// clear out the sections for any separate views that may be rendered.
$this->factory->incrementRender();
$this->factory->callComposer($this);
$contents = $this->getContents();
// Once we've finished rendering the view, we'll decrement the render count
* Get the string contents of the view.
*
* @param \Closure $callback
* @return string
*/
public function render(Closure $callback = null)
{
$contents = $this->renderContents();
$response = isset($callback) ? $callback($this, $contents) : null;
}
// If this content implements the "RenderableInterface", then we will call the
// render method on the object so we will avoid any "__toString" exceptions
// that might be thrown and have their errors obscured by PHP's handling.
elseif ($content instanceof RenderableInterface)
{
$content = $content->render();
}
* @throws \InvalidArgumentException When the HTTP status code is not valid
*
* @api
*/
public function __construct($content = '', $status = 200, $headers = array())
{
$this->headers = new ResponseHeaderBag($headers);
$this->setContent($content);
$this->setStatusCode($status);
$this->setProtocolVersion('1.0');
* @param mixed $response
* @return \Illuminate\Http\Response
*/
protected function prepareResponse($request, $response)
{
if ( ! $response instanceof SymfonyResponse)
{
$response = new Response($response);
}
$response = $this->callRouteBefore($route, $request);
if (is_null($response))
{
$response = $route->run($request);
}
$response = $this->prepareResponse($request, $response);
// After we have a prepared response from the route or filter we will call to
// If no response was returned from the before filter, we will call the proper
// route instance to get the response. If no route is found a response will
// still get returned based on why no routes were found for this request.
$response = $this->callFilter('before', $request);
if (is_null($response))
{
$response = $this->dispatchToRoute($request);
}
}
if ($this->runningUnitTests() && ! $this['session']->isStarted())
{
$this['session']->start();
}
return $this['router']->dispatch($this->prepareRequest($request));
}
{
try
{
$this->refreshRequest($request = Request::createFromBase($request));
$this->boot();
return $this->dispatch($request);
}
catch (\Exception $e)
if ($this->sessionConfigured())
{
$session = $this->startSession($request);
$request->setSession($session);
}
$response = $this->app->handle($request, $type, $catch);
// Again, if the session has been configured we will need to close out the session
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$response = $this->app->handle($request, $type, $catch);
foreach ($this->cookies->getQueuedCookies() as $cookie)
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->encrypt($this->app->handle($this->decrypt($request), $type, $catch));
}
{
$this->app = $app;
$this->middlewares = $middlewares;
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->app->handle($request, $type, $catch);
}
* @param \Symfony\Component\HttpFoundation\Request $request
* @return void
*/
public function run(SymfonyRequest $request = null)
{
$request = $request ?: $this['request'];
$response = with($stack = $this->getStackedClient())->handle($request);
$response->send();
| Once we have the application, we can simply call the run method,
| which will execute the request and send the response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have whipped up for them.
|
*/
$app->run();