MediaAttribute example


    public function create(array $params)
    {
        $this->checkPrivilege('create');

        $params = $this->prepareMediaData($params);

        $media = new MediaModel();
        $media->fromArray($params);
        $attribute = new MediaAttribute();

        if (isset($params['attribute']) && \is_array($params['attribute'])) {
            $attribute->fromArray($params['attribute']);
        }
        $media->setAttribute($attribute);

        $path = $this->prepareFilePath($media->getPath()$media->getFileName());
        $media->setPath($path);

        $violations = $this->getManager()->validate($media);
        if ($violations->count() > 0) {
            
Home | Imprint | This part of the site doesn't use cookies.