classes/Input/EncodingProviders/Zencoder.php
public function handleNotification($input)
    {
        // Parse the input
        $job = $this->sdk()->notifications->parseIncoming()->job;

        // Find the encoding model instance.  If it's not found, then just
        // ignore it.  This can easily happen if someone replaces a video
        // while one is being uploaded.
        if (!$model = Encoding::where('job_id', '=', $job->id)->first()) {
            return;
        }

        // Loop through the jobs and look for error messages.  A job may recieve a
        // seperate notification for each output that has failed though the job
        // is still processessing.
        $errors = trim(implode(' ', array_map(function ($output) {
            return isset($output->error_message) ? '(Output '.$output->label.') '.$output->error_message : null;
        }, $this->zencoderArray($job->outputs))));

        // If there were any messages, treat the job as errored.  This also tries
        // to fix an issue I saw where a final "error" notifcation wasn't fired even
        // though multiple jobs failed.
        $state = empty($errors) ? $job->state : 'failed';

        // Update the model
        switch ($state) {

            // Simple passthru of status
            case 'processing':
            case 'cancelled':
                $model->status($job->state);
                break;

            // Massage name
            case 'finished':
                $model->response = $input;
                $model->status('complete');
                break;

            // Find error messages on the output
            case 'failed':
                $model->status('error', $errors);
                break;

            // Default
            default:
                $model->status('error', 'Unkown Zencoder state: '.$job->state);
        }
    }
public function handleNotification($input)
    {
        // Parse the input
        $job = $this->sdk()->notifications->parseIncoming()->job;

        // Find the encoding model instance.  If it's not found, then just
        // ignore it.  This can easily happen if someone replaces a video
        // while one is being uploaded.
        if (!$model = Encoding::where('job_id', '=', $job->id)->first()) {
            return;
        }

        // Loop through the jobs and look for error messages.  A job may recieve a
        // seperate notification for each output that has failed though the job
        // is still processessing.
        $errors = trim(implode(' ', array_map(function ($output) {
            return isset($output->error_message) ? '(Output '.$output->label.') '.$output->error_message : null;
        }, $this->zencoderArray($job->outputs))));

        // If there were any messages, treat the job as errored.  This also tries
        // to fix an issue I saw where a final "error" notifcation wasn't fired even
        // though multiple jobs failed.
        $state = empty($errors) ? $job->state : 'failed';

        // Update the model
        switch ($state) {

            // Simple passthru of status
            case 'processing':
            case 'cancelled':
                $model->status($job->state);
                break;

            // Massage name
            case 'finished':
                $model->response = $input;
                $model->status('complete');
                break;

            // Find error messages on the output
            case 'failed':
                $model->status('error', $errors);
                break;

            // Default
            default:
                $model->status('error', 'Unkown Zencoder state: '.$job->state);
        }
    }
public function handleNotification ( $ input ) { // Parse the input $ job = $ this -> sdk ( ) -> notifications -> parseIncoming ( ) -> job ; // Find the encoding model instance.  If it's not found, then just // ignore it.  This can easily happen if someone replaces a video // while one is being uploaded. if ( ! $ model = Encoding :: where ( 'job_id' , '=' , $ job -> id ) -> first ( ) ) { return ; } // Loop through the jobs and look for error messages.  A job may recieve a // seperate notification for each output that has failed though the job // is still processessing. $ errors = trim ( implode ( ' ' , array_map ( function ( $ output ) { return isset ( $ output -> error_message ) ? '(Output ' . $ output -> label . ') ' . $ output -> error_message : null ; } , $ this -> zencoderArray ( $ job -> outputs ) ) ) ) ; // If there were any messages, treat the job as errored.  This also tries // to fix an issue I saw where a final "error" notifcation wasn't fired even // though multiple jobs failed. $ state = empty ( $ errors ) ? $ job -> state : 'failed' ; // Update the model switch ( $ state ) { // Simple passthru of status case 'processing' : case 'cancelled' : $ model -> status ( $ job -> state ) ; break ; // Massage name case 'finished' : $ model -> response = $ input ; $ model -> status ( 'complete' ) ; break ; // Find error messages on the output case 'failed' : $ model -> status ( 'error' , $ errors ) ; break ; // Default default : $ model -> status ( 'error' , 'Unkown Zencoder state: ' . $ job -> state ) ; } }
Handle notification requests from the SDK

@param  array $input Request::input()
@return mixed Reponse to the API
Handle notification requests from the SDK