(Lea) Controller\DataRename

Mardi 01 Avril 2025, 11:11:59

<?php/** * Lea * * GNU General Public License * * Copyright © 2010 - 2025, Yohann Schwan. All rights reserved. */namespace Lea\Controller {  class DataRename extends \Lys\Controller  {    /**     * @trait \Lea\DataHelper     */    use DataHelper;    /**     * @args void     * @return bool     */    function populate()    {      if(parent::populate())      {        if($row = $this->data->find($_REQUEST))        {          $_REQUEST = $row + $_REQUEST;          #          return true;        }      }    }    /**     * @args void     * @return bool     */    function execute()    {      if(parent::execute())      {        if($row = $this->data->find($_REQUEST))        {          foreach($row as $k => $v)          {            list($p, $q) = str_separate($k);            if($v2 = array_value($p . '_new_' . $q, $_REQUEST))            {              $row[$k] = $v2;            }          }          if($this->data->add($row))          {            if($this->data->remove($_REQUEST))            {              return $this->aliasOf('item', $row);            }          }        }      }    }  }}