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