PHP code example of perspeqtive / sulu-media-credits-bundle

1. Go to this page and download the library: Download perspeqtive/sulu-media-credits-bundle 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/ */

    

perspeqtive / sulu-media-credits-bundle example snippets


return [
    // ...
    PERSPEQTIVE\MediaCreditsBundle\MediaCreditsBundle::class => ['all' => true],
];

namespace App\Repository;

use PERSPEQTIVE\MediaCreditsBundle\Domain\References\ReferenceByTypeRepositoryInterface;

class MyCustomReferenceRepository implements ReferenceByTypeRepositoryInterface
{
    public function findReferences(string $mediaId): iterable
    {
        // Your logic to find references for the given mediaId
        // Should return an iterable of arrays with the following keys:
        // 'referenceTitle', 'referenceResourceId', 'referenceResourceKey', 'referenceLocale'
        yield [
            'referenceResourceId' => '123',
            'referenceResourceKey' => 'my_custom_type',
            'referenceTitle' => 'My Custom Entity Title',
            'referenceLocale' => 'en',
        ];
    }
}

namespace App\Repository;

use PERSPEQTIVE\MediaCreditsBundle\Domain\Url\UrlRepositoryByTypeInterface;

class MyCustomUrlRepository implements UrlRepositoryByTypeInterface
{
    public function find(string $id, string $locale): ?string
    {
        // Generate the URL for your custom entity
        return '/de/my-custom-entity/' . $id;
    }

    public function isResponsible(string $type): bool
    {
        return $type === 'my_custom_type';
    }
}