deblan.tv/vendor/trinity/src/Trinity/Bundle/MediaBundle/Model/TypePeer.php

33 lines
814 B
PHP
Raw Normal View History

2015-03-02 21:57:49 +01:00
<?php
namespace Trinity\Bundle\MediaBundle\Model;
use Trinity\Bundle\MediaBundle\Model\om\BaseTypePeer;
use Symfony\Component\HttpFoundation\File\File;
class TypePeer extends BaseTypePeer
{
public static function getTypeFor(File $file)
{
2015-11-25 18:28:10 +01:00
var_dump($file->getMimeType());
2015-03-02 21:57:49 +01:00
$type = TypeQuery::create()->findOneByMimes('%'.$file->getMimeType().'%');
2015-11-25 18:28:10 +01:00
var_dump($type);
die;
2015-03-02 21:57:49 +01:00
return count($type) ? $type->getId() : null;
}
public static function getTypesForType($add_auto = false)
{
$choices = $add_auto ? array('' => 'Automatic') : array();
$types = TypeQuery::create()->orderByLabel()->find();
foreach ($types as $k => $type) {
$choices[$type->getId()] = $type->getLabel();
}
return $choices;
}
}