30 lines
736 B
PHP
30 lines
736 B
PHP
|
<?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)
|
||
|
{
|
||
|
$type = TypeQuery::create()->findOneByMimes('%'.$file->getMimeType().'%');
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|