Update entry in .htaccess file

@param string $data
@param string $delim
548635
public function update($delim = '#', $data = PHP_EOL)
    {
        $data = str_replace(
            array('$1','$2','$3','$4','$5'),
            array('\$1','\$2','\$3','\$4','\$5'),
            $data
        );

        $delim = preg_quote($delim);

        file_put_contents(
            $this->file,
            trim(
                preg_replace(
                    "/#\s$delim\s(.*?)\s#\s\\\\$delim/s",
                    '# '.$delim.PHP_EOL.$data.PHP_EOL.'# \\'.$delim,
                    file_get_contents($this->file)
                )
            )
        );
    }
397882
public function update(array $data, $id)
    {
        if (array_key_exists('password', $data)) {
            $data['password'] = bcrypt($data['password']);
        }

        return parent::update($data, $id);
    }
665472
public function update($id, $data)
    {
        $message = $this->client->put(sprintf('templates/%d.json', $id), [
            'json' => $data,
        ]);

        return new Template($this->response($message));
    }
886866
public function update_config(&$data) {
        if (!empty($data->criteria_duration)) {
            $this->course = $data->id;
            $this->enrolperiod = $data->criteria_duration_days;
            $this->insert();
        }
    }
1069597
public function update_config(&$data) {
        global $DB;

        if (!empty($data->criteria_activity) && is_array($data->criteria_activity)) {

            $this->course = $data->id;

            // Data comes from advcheckbox, so contains keys for all activities.
            // A value of 0 is 'not checked' whereas 1 is 'checked'.
            foreach ($data->criteria_activity as $activity => $val) {
                // Only update those which are checked.
                if (!empty($val)) {
                    $module = $DB->get_record('course_modules', array('id' => $activity));
                    $this->module = self::get_mod_name($module->module);
                    $this->moduleinstance = $activity;
                    $this->id = null;
                    $this->insert();
                }
            }
        }
    }
123158
public function put(String $url = NULL, $data = NULL)
    {
        return $this->_customRequest($url, URL::buildQuery($this->data ?? $data), __FUNCTION__);
    }
162479
public function post($url, $data)
    {
        $request = $this->webclient->createRequest('POST', $url, array(
            'body' => $data,
        ));
        return $this->sendRequest($request);
    }
696354
public function updateFromFormData($data)
    {
        $cmsFields = $this->getCMSFields();

        foreach ($data as $field => $datum) {
            $field = $cmsFields->dataFieldByName($field);

            if (!$field) {
                continue;
            }

            $field->setSubmittedValue($datum);
            $field->saveInto($this);
        }
    }
1139949
public static function insert(&$arr, $path, $value, $delimiter = '.')
    {
        if (! static::exists($arr, $path, $delimiter)) {
            static::set($arr, $path, $value, $delimiter);
        }
    }
877154
public function execUpdate($redirectAction = false)
    {
        // database translations
        $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE));
        //validate and extract input
        $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields']));
        if($input) {
            //extract primary key value
            $primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a');
            try{
                //ORM insert
                $this->purgePrimaryKeyValue($input);
                if($this->update($primaryKeyValue, $input)) {
                    $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['update-success'], $this->translations[$this->name]['singular']));
                }
            } catch(\PDOException $exception) {
                $this->messages->save('cookies', 'danger', $this->handleError($exception));
                if(!isset($redirectAction)) {
                    $redirectAction = 'update-form/' . $this->extractPrimaryKeyValue($input, 's');
                }
            }
        }
        //redirect
        $redirectAction = $redirectAction ? $redirectAction : 'list';
        $this->httpResponse = $this->httpResponse->withHeader('Location', $redirectAction);
    }
96251
public function update($id, $data)
    {
        $this->aclDataService = $this->getServiceLocator()->get(
            \RcmUser\Acl\Service\AclDataService::class
        );

        $this->resourceProvider = $this->getServiceLocator()->get(
            \Rcm\Acl\ResourceProvider::class
        );

        /** @var \Doctrine\ORM\EntityManagerInterface $entityManager */
        $entityManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');

        $this->pageRepo = $entityManager->getRepository(\Rcm\Entity\Page::class);

        // @todo Real input validation
        if (!is_array($data)) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_400);

            return $this->getResponse();
        }

        /** @var \Rcm\Entity\Site $currentSite */
        $currentSite = $this->getServiceLocator()->get(
            \Rcm\Service\CurrentSite::class
        );

        if (!empty($data['siteId']) && is_numeric($data['siteId']) && ($currentSite->getSiteId() == $data['siteId'])) {
            $siteId = $data['siteId'];
        } else {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_400);

            return $this->getResponse();
        }

        if (is_string($data['pageName'])) {
            $pageName = $data['pageName'];
        } else {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_400);

            return $this->getResponse();
        }

        if (is_string($data['pageType']) && strlen($data['pageType']) == '1') {
            $pageType = $data['pageType'];
        } else {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_400);

            return $this->getResponse();
        }

        if (is_array($data['selectedRoles'])) {
            $selectedRoles = $data['selectedRoles'];
        } else {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_400);

            return $this->getResponse();
        }
        //CREATE RESOURCE ID
        /** @var ResourceName $resourceName */
        $resourceName = $this->getServiceLocator()->get(
            ResourceName::class
        );

        $resourceId = $resourceName->get(
            ResourceName::RESOURCE_SITES,
            $siteId,
            ResourceName::RESOURCE_PAGES,
            'n',
            $pageName
        );

        /** @var RcmUserService $rcmUserService */
        $rcmUserService = $this->getServiceLocator()->get(
            RcmUserService::class
        );

        if (!$rcmUserService->isAllowed($resourceId, 'edit')
            && !$rcmUserService->isAllowed(
                ResourceName::RESOURCE_PAGES,
                'edit'
            )
        ) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }

        //IS PAGE VALID?
        $validPage = $this->pageRepo->isValid($currentSite, $pageName, $pageType);

        if (!$validPage) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_404);

            return $this->getResponse();
        }

        if (!$this->isValidResourceId($resourceId)) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_400);

            return $this->getResponse();
        }

        //DELETE ALL PERMISSIONS
        $deleteAllPermissions = $this->deletePermissions($resourceId);

        if (!$deleteAllPermissions) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_400);

            return $this->getResponse();
        }

        $newRoles = $this->addPermissions($selectedRoles, $resourceId);

        return new JsonModel($newRoles);
    }
318126
public function addHeader($name,$required,$data) {

            $this->amfResponse->addHeader(array('name'=>$name,'required'=>$required==true,'data'=>$data));

        }
534278
public function update($data, $_id = NULL)
    {

        if ($_id) {
            $this->_id = $_id;
        }

        $parameters = [
            "id" => $this->_id,
            "body" => ['doc' => $data],
            'client' => ['ignore' => $this->ignores]
        ];

        if ($index = $this->getIndex()) {
            $parameters["index"] = $index;
        }

        if ($type = $this->getType()) {
            $parameters["type"] = $type;
        }

        return (object)$this->connection->update($parameters);
    }
249397
protected function updateUserPorfile($data)
    {
        $data = $data->except('email');

        if ($data instanceof Collection) {
            $data = $data->toArray();
        }

        if (isset($data['password'])) {
            $data['password'] = Hash::make($data['password']);
        }

        Auth::user()->update($data);
    }
375366
public function editInlineAction(Request $request, DataInterface $data)
    {
        $parameters = array_merge(
            $request->query->all(),
            [
                'familyCode' => $data->getFamilyCode(),
                'id' => $data->getId(),
            ]
        );

        return $this->redirectToAction('edit', $parameters);
    }
317373
public function save($id, array $data)
    {
        if(!empty($id) && (is_string($id) || is_numeric($id))) {
            $this->setFile($id);
            if ($this->file) {
                if (file_exists($this->file)) {
                    $this->update($id, $data);
                } else {
                    $this->add($id, $data);
                }
            }
        }
    }
922553
public function update($index, $data) {
        if (!$data instanceof Record) {
            $data = new Record(Utils::toArray($data));
        }
        $this->getFormat()->update($index, $data);
        // update buffer to reflect current changes
        if (isset($this->buffer[$index])) {
            $this->buffer[$index] = $data;
        }
    }