Build diff for a given modelHistory entry

@param  string   $currentId   UUID of ModelHistory entry to get diff for
@return void
194165
public function diff(string $currentId = null): void
    {
        $historyEntry = $this->ModelHistory->get($currentId);
        $this->FrontendBridge->setBoth('diffOutput', $this->ModelHistory->buildDiff($historyEntry));
    }
684551
public function indexAction($currentPage = 1)
    {
        // set current page
        $this->currentPage = (int)$currentPage;
        if ($this->currentPage < 1) {
            $this->currentPage = 1;
        }
        if ($this->currentPage > $this->numberOfPages) {
            // set $modifiedObjects to NULL if the page does not exist
            $modifiedObjects = null;
        } else {
            // modify query
            $this->itemsPerPage = (int)$this->configuration['itemsPerPage'];
            $this->offset = $this->itemsPerPage * ($this->currentPage - 1);
            // use slice here for array support
            $modifiedObjects = $this->prepareObjectsSlice($this->itemsPerPage, $this->offset);
        }
        $this->view->assign('contentArguments', [
            $this->widgetConfiguration['as'] => $modifiedObjects,
        ]);
        $this->view->assign('configuration', $this->configuration);
        $this->view->assign('pagination', $this->buildPagination());
    }
852451
public function actionDiff()
	{
		Yii::import('gii.components.TextDiff');

		$model=$this->prepare();
		if(isset($_GET['id']) && isset($model->files[$_GET['id']]))
		{
			$file=$model->files[$_GET['id']];
			if(!in_array($file->type,array('php', 'txt','js','css','sql')))
				$diff=false;
			elseif($file->operation===CCodeFile::OP_OVERWRITE)
				$diff=TextDiff::compare(file_get_contents($file->path), $file->content);
			else
				$diff='';

			$this->renderPartial('/common/diff',array(
				'file'=>$file,
				'diff'=>$diff,
			));
		}
		else
			throw new CHttpException(404,'Unable to find the code you requested.');
	}
461409
public function historyAction($id = null)
    {
        $request = $this->getRequest();
        $id = $request->get($this->admin->getIdParameter());

        $object = $this->admin->getObject($id);

        if (!$object) {
            throw $this->createNotFoundException(sprintf('unable to find the object with id: %s', $id));
        }

        $this->admin->checkAccess('history', $object);

        $manager = $this->get('sonata.admin.audit.manager');

        if (!$manager->hasReader($this->admin->getClass())) {
            throw $this->createNotFoundException(
                sprintf(
                    'unable to find the audit reader for class : %s',
                    $this->admin->getClass()
                )
            );
        }

        $reader = $manager->getReader($this->admin->getClass());

        $revisions = $reader->findRevisions($this->admin->getClass(), $id);

        // NEXT_MAJOR: Remove this line and use commented line below it instead
        $template = $this->admin->getTemplate('history');
        // $template = $this->templateRegistry->getTemplate('history');

        return $this->renderWithExtraParams($template, [
            'action' => 'history',
            'object' => $object,
            'revisions' => $revisions,
            'currentRevision' => $revisions ? current($revisions) : false,
        ], null);
    }
1048738
protected function buildMenuItemRecursive(NodeInterface $currentNode)
    {
        if ($this->isNodeHidden($currentNode)) {
            return null;
        }

        $item = [
            'node' => $currentNode,
            'state' => self::STATE_NORMAL,
            'label' => $currentNode->getLabel(),
            'menuLevel' => $this->currentLevel
        ];

        $item['state'] = $this->calculateItemState($currentNode);
        if (!$this->isOnLastLevelOfMenu($currentNode)) {
            $this->currentLevel++;
            $item['subItems'] = $this->buildMenuLevelRecursive($currentNode->getChildNodes($this->getFilter()));
            $this->currentLevel--;
        }

        return $item;
    }
501933
public function regenerateNav($layoutId, $generatedNav, $currentNav)
    {
        // Find the extra or missing menu item
        if (count($generatedNav) < count($currentNav)) {
            $order = 0;

            // A menu item exists in the menu, but not in our records - add
            foreach ($currentNav as $value) {
                if (isset($value['url'])) {
                    $handle = str_replace(UrlHelper::url() . '/', '', $value['url']);
                } else {
                    $handle = StringHelper::toKebabCase($value['label']);
                }

                if (!isset($generatedNav[$handle]) && !CpNav::$plugin->navigationService->getByHandle($layoutId, $handle)) {
                    $icon = null;

                    // Check for custom icon (plugins)
                    if (isset($value['icon'])) {
                        $icon = $value['icon'];
                    }

                    // Check for built-in Craft icon
                    if (isset($value['fontIcon'])) {
                        $icon = $value['fontIcon'];
                    }

                    $model = $this->_prepareNavModel([
                        'layoutId' => $layoutId,
                        'handle'   => $handle,
                        'label'    => $value['label'],
                        'order'    => $order,
                        'icon'     => $icon,
                        'url'      => $handle,
                    ]);

                    CpNav::$plugin->navigationService->save($model);
                }

                $order++;
            }
        } else {

            // Create an array of current navigation handles to easy check via in_array
            $currentNavHandles = array_column($currentNav, 'url');

            // A menu item exists in our records, but not in the menu - delete
            foreach ($generatedNav as $key => $value) {
                if (!\in_array($value['handle'], $currentNavHandles, false)) {
                    $navModel = CpNav::$plugin->navigationService->getByHandle($layoutId, $value['handle']);

                    if ($navModel) {
                        CpNav::$plugin->navigationService->delete($navModel);
                    }
                }
            }
        }
    }
1228740
public function setRelationshipOnUpdate(
        AccountInterface $current,
        Model $model,
        $relationshipName,
        $idx,
        $relModelClass
    ) {
        $current && $model && $relationshipName ?: null;

        $isAllowed = true;
        if ($idx !== null) {
            // find model by id and check if it exists
            /** @noinspection PhpUndefinedMethodInspection */
            $relModel  = $relModelClass::find($idx);
            $isAllowed = $relModel !== null && $this->getGuard()->allows(self::CAN_READ, [$relModel]);
        }

        return $isAllowed;
    }
1018418
public function withCurrentState(string $current_state): OutputInterface
    {
        $output = clone $this;
        $output->current_state = $current_state;
        return $output;
    }
264682
public function actionUpdate($id)
    {
        $this->layout = static::FORM_LAYOUT;
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            $current_model = $this->findModel($id);
            if($current_model->Menu_id != $model->Menu_id){
                if($model->Menu_id) {
                    $parent_node = Menu::findOne($model->Menu_id);
                    $model->appendTo($parent_node);
                } else {
                    $model->makeRoot();
                }
            } else {
                $model->save(false);
            }

            $this->saveHistory($model, $this->historyField);
            return $this->redirect(['index']);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
158298
public static function sortTree(Directory $current) {
        $current->sort();
        foreach ($current->getEntries() as $entry) {
            if ($entry instanceof Directory) {
                Builder::sortTree($entry);
            }
        }
    }
95700
public function versionPickerAction($id, $current, $published = 0)
    {
        if ($this->getDoctrine()->getManager()->getFilters()->isEnabled('draftversion')) {
            $this->getDoctrine()->getManager()->getFilters()->disable('draftversion');
        }

        /** @var BlockManager $manager */
        $manager = $this->get('opifer.content.block_manager');
        $block   = $manager->find($id);

        $logEntries = $manager->getRootVersions($block);

        return $this->render('OpiferContentBundle:Editor:version_picker.html.twig', ['logentries' => $logEntries, 'current' => $current, 'published' => $published]);
    }
180133
public static Message buildDiff(Zxid lastZxid) {
    ZabMessage.Zxid lz = toProtoZxid(lastZxid);

    Diff diff = Diff.newBuilder().setLastZxid(lz).build();

    return Message.newBuilder().setType(MessageType.DIFF)
                               .setDiff(diff)
                               .build();
  }
252111
public function setModelId($modelId)
    {
        $this->modelId = (string)$modelId;
        $this->model   = null;
        return $this;
    }
1146402
function diff( $old, $new, $options = false )
    {
        $diff = new eZDiff();
        $diff->setDiffEngineType( $diff->engineType( 'container' ) );
        $diff->initDiffEngine();
        $diffObject = $diff->diff( $old, $new );
        return $diffObject;
    }
285342
public function build(array $items, $currentUri)
    {
        foreach ($items as $item) {
            if ($item->isDivider()) {
                continue;
            }

            $this->buildItem($item, $currentUri);
        }

        return $items;
    }
584998
public static function data_for_messagearea_get_profile($currentuserid, $otheruserid) {
        global $CFG, $PAGE, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        $systemcontext = context_system::instance();

        $params = array(
            'currentuserid' => $currentuserid,
            'otheruserid' => $otheruserid
        );
        $params = self::validate_parameters(self::data_for_messagearea_get_profile_parameters(), $params);
        self::validate_context($systemcontext);

        if (($USER->id != $params['currentuserid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
            throw new moodle_exception('You do not have permission to perform this action.');
        }

        $profile = \core_message\api::get_profile($params['currentuserid'], $params['otheruserid']);
        $profile = new \core_message\output\messagearea\profile($profile);

        $renderer = $PAGE->get_renderer('core_message');
        return $profile->export_for_template($renderer);
    }
613464
protected function mappingCurrentModel($currentModel)
    {
        if ($currentModel instanceof Model) {
            $this->currentModel = $currentModel;
            $this->currentTable = $this->currentModel->table;
            $this->currentPrimaryKey = $this->currentModel->primaryKey;
        } elseif (class_exists($currentModel)) {
            $this->currentModel = models($currentModel);
            $this->currentTable = $this->currentModel->table;
            $this->currentPrimaryKey = $this->currentModel->primaryKey;
        } else {
            $this->currentTable = $currentModel;
            $this->currentPrimaryKey = 'id';
        }
    }