<?php
/**
* Perforce Swarm, Community Development
*
* @copyright 2014 Perforce Software. All rights reserved.
* @license Please see LICENSE.txt in top-level folder of this distribution.
* @version <release>/<patch>
*/
namespace Avatar;
use Zend\Mvc\MvcEvent;
class Module
{
/**
* Modify the project filter to:
* - allow users to upload an optional workshop avatar and splash image
*
* @param MvcEvent $event the bootstrap event
* @return void
*/
public function onBootstrap(MvcEvent $event)
{
$application = $event->getApplication();
$services = $application->getServiceManager();
$filters = $services->get('InputFilterManager');
$projectFilter = $filters->get('ProjectFilter');
$projectFilter->add(
array(
'name' => 'avatar',
'required' => false
)
);
$projectFilter->add(
array(
'name' => 'project-avatar',
'required' => false,
'validators' => array(
array(
'name' => 'File/MimeType',
'options' => array(
'mimeType' => 'image/jpg,image/jpeg,image/png'
)
),
array(
'name' => 'File/ImageSize',
'options' => array(
'minWidth' => 128,
'minHeight' => 128,
'maxWidth' => 1024,
'maxHeight' => 1024,
),
),
array(
'name' => 'File/Size',
'options' => array(
'min' => 1024,
'max' => 1024 * 1024,
)
)
)
)
);
$projectFilter->add(
array(
'name' => 'splash',
'required' => false
)
);
$projectFilter->add(
array(
'name' => 'project-splash',
'required' => false,
'validators' => array(
array(
'name' => 'File/MimeType',
'options' => array(
'mimeType' => 'image/jpg,image/jpeg,image/png,image/gif'
)
),
array(
'name' => 'File/ImageSize',
'options' => array(
'minWidth' => 128,
'minHeight' => 128,
'maxWidth' => 900,
'maxHeight' => 255,
),
),
array(
'name' => 'File/Size',
'options' => array(
'min' => 1024,
'max' => 1024 * 1024,
)
)
)
)
);
$filters->setService('ProjectFilter', $projectFilter);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
}
# |
Change |
User |
Description |
Committed |
|
#1
|
15568 |
Matt Attaway |
Move all of the workshop files into main branch to make Workshop happy |
|
|
//guest/perforce_software/workshop/avatar/module/Avatar/Module.php |
#1
|
10189 |
Matt Attaway |
Publish the source code for the Workshop avatar module |
|
|