PHP code example of carbon / link

1. Go to this page and download the library: Download carbon/link library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

carbon / link example snippets




class ArticlesController extends ActionController
{
    ...

    public function listAction(): void
    {
        $workspaceName = 'live';
        $language = 'en';

        $contextProperties = [
            'workspaceName' => $workspaceName,
            'invisibleContentShown' => false,
            'inaccessibleContentShown' => false,
            'dimensions' => [
                'language' => [$language]
            ],
            'targetDimensions' => [
                'language' => $language
            ]
        ];

        $currentDomain = $this->domainRepository->findOneByActiveRequest();

        if ($currentDomain !== null) {
            $contextProperties['currentSite'] = $currentDomain->getSite();
            $contextProperties['currentDomain'] = $currentDomain;
        } else {
            $contextProperties['currentSite'] = $this->siteRepository->findFirstOnline();
        }

        $contentContext = $this->contextFactory->create($contextProperties);

        $site = $contentContext->getCurrentSiteNode();

        $this->view->assign('documentNode', $site);
    }
}