@inheritdoc

@throws \common_exception_InconsistentData
490667
public function getTheme()
    {
        $themeId = $this->getThemeIdFromThemeDetailsProviders();
        if (empty($themeId)) {
            $themeId = $this->getCurrentThemeId();
        }

        return $this->getThemeById($themeId);
    }
368740
protected function checkRequiredData()
    {
        if (!isset($this->data)) {
            throw new RuntimeException("'data' property is required for DataAwareTrait to work");
        }
        if (!isset($this->requiredData)) {
            throw new RuntimeException("'requiredData' property is required for DataAwareTrait to work");
        }

        $missing = [];
        foreach ($this->requiredData as $key) {
            if (!isset($this->data[$key])) {
                $missing []= $key;
            }
        }

        if (!count($missing)) {
            return true;
        }

        throw new RuntimeException(
            sprintf("Missing required data field(s) [%s]", implode(",", array_map([$this,"camelize"], $missing)))
        );
    }
281621
protected function _handleDatabaseException(Zend_Db_Statement_Exception $e) {
        if (strpos($e->getMessage(), 'Duplicate entry') === false) {
            throw $e;
        }
        // Note the double spaces in the template string are required since quotes would be
        // added greedily to the parsed values.
        list($value, $index) = sscanf($e->getMessage(),
            'SQLSTATE[23000]: Integrity constraint violation: ' .
            '1062 Duplicate entry  %s  for key  %s ');

        // Throw an exception with a human-friendly error
        throw new Exception(
            sprintf(__('%s is already in use, please provide a unique value.'), $value));
    }
871656
public function process($value)
        {

            if ($this->isMandatory() && !$value)
            {
                throw new Exception($this->getMessage(self::IS_MISSING, ['param', $this->reference]));
            }

            $dataProcessor = $this->getDataProcessor();

            if ($dataProcessor instanceof ApplicationAwareInterface)
            {
                $dataProcessor->setApplication($this->getApplication());
            }

            $processedValue = $dataProcessor->process($value);

            if($this->isMandatory() && is_null($processedValue))
            {
                throw new Exception($this->getMessage(self::IS_MISSING, ['param', $this->reference]));
            }

            return $processedValue;
        }
840724
private function validateCheckerConditionsAndThrowFailureExceptionOnFailedCheck(
        CheckInterface $checker,
        array $arguments,
        $errorText
    ) {
        $validatorData = $checker($arguments);

        if ($validatorData !== true) {
            if (is_array($validatorData)) {
                throw new FailureException(sprintf($errorText, ...$validatorData));
            }

            throw new FailureException($errorText);
        }

        return true;
    }
655706
public function updateDeferred()
    {
        try {
            if ($this->getRequestMethod() !== \Request::HTTP_POST) {
                throw new \common_exception_NotImplemented('Only post method is accepted to updating delivery');
            }
            if (! $this->hasRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)) {
                throw new \common_exception_MissingParameter(self::REST_DELIVERY_SEARCH_PARAMS, $this->getRequestURI());
            }
            $where = json_decode(html_entity_decode($this->getRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)), true);
            $propertyValues = $this->getRequestParameters();
            unset($propertyValues[self::REST_DELIVERY_SEARCH_PARAMS]);

            $task = UpdateDelivery::createTask($where, $propertyValues);

            $result = [
                'reference_id' => $task->getId()
            ];

            /** @var TaskLogInterface $taskLog */
            $taskLog = $this->getServiceManager()->get(TaskLogInterface::SERVICE_ID);
            $report = $taskLog->getReport($task->getId());
            if (!empty($report)) {
                if ($report instanceof \common_report_Report) {
                    //serialize report to array
                    $report = json_decode($report);
                }
                $result['common_report_Report'] = $report;
            }
            return $this->returnSuccess($result);
        }catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
804320
protected static function assertItIsArray($data, ErrorBag $errorBag)
    {
        if (empty($data) || !is_array($data)) {
            $errorBag->offsetSet(null, new MissingDataError());
            throw new DataException();
        }
    }
1155938
protected function writeUnexpectedResponseExceptionTemplate()
	{
		$data = $this->unexpectedResponseExceptionData;

		$filePath = $this->outputPath . DIRECTORY_SEPARATOR . 'Exceptions' . DIRECTORY_SEPARATOR . 'UnexpectedResponseException.php';

		if (!is_null($this->outputInterface)) {
			$this->outputInterface->writeln('<info>Writing ' . $filePath . '</info>');
		}

		file_put_contents($filePath, $this->unexpectedResponseExceptionTemplate->render($data));
	}
39850
protected void inconsistent(K key, StoreAccessException because, StoreAccessException... cleanup) {
    pacedErrorLog("Ehcache key {} in possible inconsistent state", key, because);
  }
104869
public function feedDataTable()
    {
        if (!$this->isXmlHttpRequest()) {
            throw new \Exception('Only ajax call allowed.');
        }

        if (!$this->hasRequestParameter(self::PARAMETER_COLUMNS)) {
            throw new common_Exception('Parameter "'. self::PARAMETER_COLUMNS .'" missing');
        }

        $this->returnJson((new ResultsPayload($this->getExporterService()->getExporter()))->getPayload());
    }
1271296
private function createData() : void
    {
        $this->data = [
            'foo' => 'some foo string',
            'bar' => 42,
            'baz' => new DateTime(),
            'someFooProperty' => [12, 13, 14],
            'someBarProperty' => 12354.4578,
            'someBazProperty' => new stdClass(),
            'foo1' => 'some foo string',
            'bar1' => 42,
            'baz1' => new DateTime(),
            'someFooProperty1' => [12, 13, 14],
            'someBarProperty1' => 12354.4578,
            'someBazProperty1' => new stdClass(),
            'foo2' => 'some foo string',
            'bar2' => 42,
            'baz2' => new DateTime(),
            'someFooProperty2' => [12, 13, 14],
            'someBarProperty2' => 12354.4578,
            'someBazProperty2' => new stdClass(),
        ];
    }
98064
public function evaluate($values)
    {
        $returnValue = (bool) false;

        if ($this->hasOption('function')) {
			$function = $this->getOption('function');
            if (function_exists($function)) {
                $callback = array($function);
            } else {
                throw new common_Exception("callback function does not exist");
            }
        } else if ($this->hasOption('class')) {
			$class = $this->getOption('class');
			$method = $this->getOption('method');
            if (class_exists($class) && method_exists($class, $method)) {
                $callback = array($class, $method);
            } else {
                throw new common_Exception("callback method does not exist");
            }
        } else if ($this->hasOption('object')) {
			$object = $this->getOption('object');
			$method = $this->getOption('method');
            if (method_exists($object, $method)) {
                $callback = array($object, $method);
            } else {
                throw new common_Exception("callback method does not exist");
            }
		}

        if ($this->hasOption('param')) {
            $returnValue = (bool)call_user_func($callback, $values, $this->getOption('param'));
        } else {
            $returnValue = (bool)call_user_func($callback, $values);
        }

        return (bool)$returnValue;
    }
653752
public function upload()
    {
        try {
            if ($this->getRequestMethod() !== \Request::HTTP_POST) {
                throw new \common_exception_NotImplemented('Only post method is accepted.');
            }
            if (!isset($_POST['upload']) || !is_string($_POST['upload'])) {
                throw new \common_exception_InconsistentData("'upload' POST variable is missed.");
            }
            $size = mb_strlen($_POST['upload'], '8bit');
            $result = ['success' => true, 'size' => $size];
        } catch (\common_exception_NotImplemented $e) {
            $result = ['success' => false, 'error' => $e->getMessage()];
            $this->logWarning($e->getMessage());
        } catch (\common_exception_InconsistentData $e) {
            $result = ['success' => false, 'error' => $e->getMessage()];
            $this->logWarning($e->getMessage());
        } catch (\Exception $e) {
            $result = ['success' => false, 'type' => 'error', 'message' => 'Please contact administrator'];
            $this->logWarning($e->getMessage());
        }
        $this->returnJson($result);
    }
1364029
public function fileExists()
    {
        if (!$this->hasRequestParameter('uri') || !$this->hasRequestParameter('path') || !$this->hasRequestParameter('lang')) {
            throw new common_exception_MissingParameter();
        }

        $item = $this->getResource($this->getRequestParameter('uri'));
        $itemLang = $this->getRequestParameter('lang');

        try {
            $resolver = new ItemMediaResolver($item, $itemLang);
            $asset = $resolver->resolve($this->getRequestParameter('path'));
            $asset->getMediaSource()->getFileInfo($asset->getMediaIdentifier());
            $found = true;
        } catch (tao_models_classes_FileNotFoundException $exception) {
            $found = false;
        }
        return $this->returnJson(array(
            'exists' => $found
        ));
    }
1368971
public function duplicate(Model $Model, $data, $config = array()) {
		$config = array_merge($this->settings[$Model->alias], $config);

		if (empty($Model->id) && empty($data[$Model->alias][$Model->primaryKey])) {
			throw new Exception(__d('common', "Missing primary key for duplicatable '%s' data", $Model->name));
		}

		$id = $Model->id ? $Model->id : $data[$Model->alias][$Model->primaryKey];
		$conditions = array($Model->primaryKey => $id) + (array) $this->settings[$Model->alias]['scope'];

		if (
			!empty($this->settings[$Model->alias]['scope'])
			&& !$Model->find('count', compact('conditions'))
		) {
			return false;
		}

		$duplicateData = array(
			$config['duplicatedKey'] => $id,
			$config['duplicatedModel'] => (!empty($Model->plugin) ? $Model->plugin . '.' : '') . $Model->name
		);

		$DuplicateModel = ClassRegistry::init($config['model']);
		$DuplicateModel->create();

		$duplicateRecord = $DuplicateModel->find('first', array('conditions' => $duplicateData, 'recursive' => -1));
		if (!empty($duplicateRecord)) {
			$DuplicateModel->id = $duplicateRecord[$DuplicateModel->alias][$DuplicateModel->primaryKey];
		}

		foreach ((array) $config['mapFields'] as $field => $path) {
			$value = Hash::extract($data, $path);
			$duplicateData[$field] = array_pop($value);
			if (
				!empty($duplicateRecord[$DuplicateModel->alias][$field])
				&& $duplicateRecord[$DuplicateModel->alias][$field] === $duplicateData[$field]
			) {
				unset($duplicateData[$field]);
			}
		}

		if (
			(empty($duplicateRecord) || 1 < count($duplicateData))
			&& (!empty($DuplicateModel->id) || $DuplicateModel->create($duplicateData))
			&& !$DuplicateModel->save()
		) {
			return false;
		}

		return true;
	}
268924
protected function checkJsonObjectOrArray(\SwaggerValidator\Common\Context $context, &$jsonData)
    {
        if (is_object($jsonData) && !($jsonData instanceof \stdClass)) {
            $context->throwException('Mismatching type of JSON Data received', get_class($this) . '::' . __METHOD__, __LINE__);
        }
        elseif (!is_object($jsonData) && !is_array($jsonData)) {
            $context->throwException('Mismatching type of JSON Data received', get_class($this) . '::' . __METHOD__, __LINE__);
        }

        if (is_array($jsonData)) {
            parent::setJSONIsArray();
        }

        return true;
    }
984153
public function getPath()
    {
        $adapter = $this->getFileSystem()->getAdapter();
        if (!$adapter instanceof Local) {
            throw new common_exception_InconsistentData(__CLASS__.' can only handle local files');
        }
        return $adapter->getPathPrefix() . $this->getPrefix();
    }