Skip to content

Instantly share code, notes, and snippets.

View jmather's full-sized avatar

Jacob Mather jmather

View GitHub Profile
@jmather
jmather / majaxMediaRegistryEntryEmbeddedForm.class.php
Created January 29, 2011 05:37
Example of how to prepare a form for embedding
public function configure()
{
parent::configure();
unset($this['id']);
unset($this['uuid'], $this['video_media'], $this['audio_media'], $this['photo_media'], $this['gallery_media']);
unset($this['created_at'], $this['updated_at']);
$gal_widget_opts = array('multiple' => true, 'model' => 'majaxMediaGallery');
if ($this->getObject()->getType() == 'Gallery')
{
$gal_widget_opts['exclude'] = $this->getObject()->getObject()->id;
@jmather
jmather / PluginmajaxMediaVideoForm.class.php
Created January 29, 2011 05:42
How to use embedded media registry form
$f = new majaxMediaRegistryEntryEmbeddedForm($this->getObject()->MediaRegistryEntry);
$f->updateDefaultsFromObject();
$this->embedMergeForm('media', $f);
@jmather
jmather / majaxMediaRegistryEntryEmbeddedForm.class.php
Created January 29, 2011 05:57
How to trick embedded forms into thinking they are bound
public function isValid()
{
return true;
}
public function processValues($values)
{
$this->values = parent::processValues($values);
$this->isBound = true;
return $this->values;
}
@jmather
jmather / majaxMediaRegistryEntryEmbeddedForm.class.php
Created January 29, 2011 05:59
How to force a many-to-many relationship to be saved by overriding saveEmbeddedForms
public function saveEmbeddedForms($con = null, $forms = null)
{
$this->saveGalleriesList($con);
parent::saveEmbeddedForms($con, $forms);
}
@jmather
jmather / ExampleForm.class.php
Created January 29, 2011 06:26
How you can post validate embedded forms
class TestForm
{
public function configure()
{
// ... snip ...
$eForm = new SomeObjectEmbeddedForm($this->getObject()->SomeObject);
$this->embedForm('some_object', $eForm);
$this->validatorSchema->setPostValidator(
public function configureDoctrine(Doctrine_Manager $manager)
{
$options = array('baseClassName' => 'myDoctrineRecord');
sfConfig::set('doctrine_model_builder_options', $options);
}
@jmather
jmather / ProjectConfiguration.class.php
Created March 3, 2011 15:39
How to enable identifier quoting with Doctrine in symfony
<?php
class ProjectConfiguration extends sfProjectConfiguration
{
// ...
public function configureDoctrine(Doctrine_Manager $manager)
{
$manager->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);
}
@jmather
jmather / httpd.conf
Created March 3, 2011 16:07
The chunk you need to ensure is in there for .htaccess files to work
<Directory "/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
$this->executor->setExecutable($ffmpeg);
$this->executor->setArguments($args);
$this->executor->execute();
@jmather
jmather / majaxMediaFFMpeg.class.php
Created March 18, 2011 09:08
This is before trying to make this code testable. This is one small piece of a larger class...
<?php
// ... snip ...
public function process(majaxMediaFileInfo $file_info, $new_width = null, $new_height = null, $crop_method = 'fit', $aspect_ratio = '16:9')
{
$name = $file_info->getName();
$sha1 = $file_info->getSha1();
$path = $this->path_builder->render($sha1);
$full_path = sfConfig::get('app_majax_media_cache_dir').DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$name;
if (!file_exists(sfConfig::get('app_majax_media_cache_dir').DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$name))