2017 © Pedro PelΓ‘ez
 

symfony-bundle attach-file-bundle

Symfony2 bundle. The ability to attach files to the form.

image

it-blaster/attach-file-bundle

Symfony2 bundle. The ability to attach files to the form.

  • Monday, February 1, 2016
  • by 0x2f8f
  • Repository
  • 5 Watchers
  • 0 Stars
  • 157 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

AttachFileBundle

Build Status Scrutinizer Code Quality, (*1)

Π’ΡΠΏΠΎΠΌΠΎΠ³Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ Π±Π°Π½Π΄Π» для Ρ€Π°Π±ΠΎΡ‚Ρ‹ с Ρ„Π°ΠΉΠ»Π°ΠΌΠΈ Π½Π° сайтС. Π•ΡΡ‚ΡŒ Π²ΠΎΠ·ΠΌΠΆΠ½ΠΎΡΡ‚ΡŒ ΠΏΡ€ΠΈΠΊΡ€Π΅ΠΏΠ»ΡΡ‚ΡŒ нСсколько Ρ„Π°ΠΉΠ»ΠΎΠ² ΠΊ ΠΎΠ΄Π½ΠΎΠΉ сущности. Π•ΡΡ‚ΡŒ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° языковых вСрсий., (*2)

Installation

Π”ΠΎΠ±Π°Π²ΡŒΡ‚Π΅ ItBlasterAttachFileBundle Π² composer.json:, (*3)

{
    "require": {
        "it-blaster/attach-file-bundle": "dev-master"
    },
}

Π’Π΅ΠΏΠ΅Ρ€ΡŒ запуститС ΠΊΠΎΠΌΠΏΠΎΠ·Π΅Ρ€, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΡΠΊΠ°Ρ‡Π°Ρ‚ΡŒ Π±Π°Π½Π΄Π» ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ:, (*4)

``` bash $ php composer.phar update it-blaster/attach-file-bundle, (*5)


ΠšΠΎΠΌΠΏΠΎΠ·Π΅Ρ€ установит Π±Π°Π½Π΄Π» Π² ΠΏΠ°ΠΏΠΊΡƒ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° `vendor/it-blaster/attach-file-bundle`. Π”Π°Π»Π΅Π΅ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΡ‚Π΅ Π±Π°Π½Π΄Π» Π² ядрС `AppKernel.php`: ``` php <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new ItBlaster\AttachFileBundle\ItBlasterAttachFileBundle(), ); }

Π’ app/config/config.yml Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΡƒΠΊΠ°Π·Π°Ρ‚ΡŒ ΠΏΡƒΡ‚ΡŒ Π΄ΠΎ класса Π±ΠΈΡ…Π΅ΠΉΠ²ΠΎΡ€Π° it_blaster_file ΠΈ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ шаблон Π²ΠΈΠ΄ΠΆΠ΅Ρ‚Π° attach_file:, (*6)

``` bash propel: ... behaviors: ... it_blaster_file: ItBlaster\AttachFileBundle\Behavior\AttachFileBehavior, (*7)

twig: form: resources: - 'ItBlasterAttachFileBundle:Form:attach_file_widget.html.twig', (*8)

assetic: bundles: - 'ItBlasterAttachFileBundle', (*9)


Π’ Ρ„Π°ΠΉΠ» app/config/routing.yml Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ Ρ€ΠΎΡƒΡ‚ΠΈΠ½Π³-Ρ„Π°ΠΉΠ» Π±Π°Π½Π΄Π»Π°: ``` bash attach_file: resource: '@ItBlasterAttachFileBundle/Resources/config/routing.yml'

Usage

Π’ Ρ„Π°ΠΉΠ»Π΅ schema.yml ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΡ‚Π΅ Π±ΠΈΡ…Π΅ΠΉΠ²ΠΎΡ€ it_blaster_file ``` xml, (*10)

Π’ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π΅ <b>file_columns</b> Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΡƒΠΊΠ°Π·Π°Ρ‚ΡŒ имя поля изобраТСния. Π’ Π΄Π°Π½Π½ΠΎΠΌ ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π΅ этим ΠΏΠΎΠ»Π΅ΠΌ являСтся ΠΏΠΎΠ»Π΅ <b>image</b>. Если ΠΊ сущности Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΠΏΡ€Π΅ΠΊΡ€Π΅ΠΏΠ»ΡΡ‚ΡŒ нСсколько Ρ„Π°ΠΉΠ»ΠΎΠ², названия ΠΏΠΎΠ»Π΅ΠΉ Π² ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π΅ <b>file_columns</b> Π½ΡƒΠΆΠ½ΠΎ ΡƒΠΊΠ°Π·Π°Ρ‚ΡŒ Ρ‡Π΅Ρ€Π΅Π· Π·Π°ΠΏΡΡ‚ΡƒΡŽ, Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€:
``` xml


Поля Ρ„Π°ΠΉΠ»ΠΎΠ² Π΄ΠΎΠ»ΠΆΠ½Ρ‹ ΠΈΠΌΠ΅Ρ‚ΡŒ Ρ‚ΠΈΠΏ integer, (*11)

Π”Π°Π»Π΅Π΅ Π² описании Ρ„ΠΎΡ€ΠΌΡ‹ рСдактирования Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ ΠΏΠΎΠ»Π΅ прикрСплСния Ρ„Π°ΠΉΠ»Π°: ``` php $formMapper ->add('image_file', 'attach_file', array( 'label' => 'Π˜Π·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅', 'required' => false, 'constraints' => [ new Image([ 'mimeTypes' => [ 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png' ] ]) ], (*12)

    ));
ΠžΠ±Ρ€Π°Ρ‚ΠΈΡ‚Π΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, Ρ‡Ρ‚ΠΎ ΠΏΠΎΠ»Π΅ называСтся Π½Π΅ `image`, Π° `image_file`. Π­Ρ‚ΠΎ ΠΏΠΎΠ»Π΅ image_file ΠΈ ΡΠΎΠΎΡ‚Π²Π΅Ρ‚ΡΡ‚Π²ΡƒΡŽΡ‰ΠΈΠ΅ ΠΌΠ΅Ρ‚ΠΎΠ΄Ρ‹ get ΠΈ set создал Π±ΠΈΡ…Π΅ΠΉΠ²ΠΎΡ€ <b>AttachFileBehavior</b>, ΠΎΠ½ΠΈ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽΡ‚ΡΡ ΠΈΡΠΊΠ»ΡŽΡ‡ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ для Ρ„ΠΎΡ€ΠΌΡ‹ рСдактирования.

Use i18n
-------
Если Π²Ρ‹ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚Π΅ языковыС вСрсии Π½Π° сайтС Π½Π° основС propel-Π±ΠΈΡ…Π΅ΠΉΠ²ΠΎΡ€Π° `i18n` ΠΈ ΠΊ ΠΊΠ°ΠΆΠ΄ΠΎΠΌΡƒ ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ΄Ρƒ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΠΏΡ€ΠΈΠΊΡ€Π΅ΠΏΠ»ΡΡ‚ΡŒ Ρ„Π°ΠΉΠ», Ρ‚ΠΎ Π²Π°ΠΌ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ Π² основной Ρ‚Π°Π±Π»ΠΈΡ†Π΅ (<b>document</b>) ΡƒΠΊΠ°Π·Π°Ρ‚ΡŒ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ `i18n`, Π³Π΄Π΅ Π±ΡƒΠ΄Π΅Ρ‚ имя поля Ρ„Π°ΠΉΠ»Π°, ΠΈ Π² ΡΠΎΠΎΡ‚Π²Π΅Ρ‚ΡΡ‚Π²ΡƒΡŽΡ‰Π΅ΠΉ Ρ‚Π°Π±Π»ΠΈΡ†Π΅ с ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ΄Π°ΠΌΠΈ (<b>document_i18n</b>) ΡƒΠΊΠ·Π°Ρ‚ΡŒ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ `file_columns`, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ Π±ΡƒΠ΄Π΅Ρ‚ Ρ‚ΠΎ ΠΆΠ΅ самоС Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ поля Ρ„Π°ΠΉΠ»Π°. ΠŸΡ€ΠΈΠΌΠ΅Ρ€:
``` xml


<table name="document_i18n"> <behavior name="it_blaster_file" > <parameter name="file_columns" value="download" /> </behavior> </table>

Π”Π°Π»Π΅Π΅ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π°Π΅ΠΌ Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ attach_file Π² Π°Π΄ΠΌΠΈΠ½-Ρ„ΠΎΡ€ΠΌΠ΅: xml $formMapper ->add('DocumentI18ns', new TranslationCollectionType(), [ 'label' => false, 'required' => false, 'type' => new TranslationType(), 'languages' => $this->getConfigurationPool()->getContainer()->getParameter('locales'), 'options' => [ 'label' => false, 'data_class' => 'Artsofte\MainBundle\Model\DocumentI18n', 'columns' => [ 'active' => [ 'label' => "ΠžΠΏΡƒΠ±Π»ΠΈΠΊΠΎΠ²Π°Ρ‚ΡŒ", 'type' => 'checkbox', ], 'file_title' => [ 'label' => "Имя Ρ„Π°ΠΉΠ»Π°", 'type' => 'text', 'required' => true, ], 'download_file' => array( 'type' => 'attach_file', 'label' => 'Π’Ρ‹Π±Π΅Ρ€ΠΈΡ‚Π΅ Ρ„Π°ΠΉΠ»', 'maxSize' => '20M', 'options' => [ 'sonata_help' => 'ДопустимыС Ρ‚ΠΈΠΏΡ‹ Ρ„Π°ΠΉΠ»ΠΎΠ²: pdf, doc, docx, zip, jpg, gif, png', 'constraints' => [ new \Symfony\Component\Validator\Constraints\File([ 'mimeTypes' => [ 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.oasis.opendocument.text', 'application/zip', 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png' ] ]) ] ] ), ] ] ]) ;, (*13)

Credits

It-Blaster it-blaster@yandex.ru, (*14)

The Versions

01/02 2016

dev-master

9999999-dev https://github.com/it-blaster/attach-file-bundle

Symfony2 bundle. The ability to attach files to the form.

  Sources   Download

MIT

The Requires

 

by IT-Blaster

form behavior type sluggable

01/02 2016

v1.0.1

1.0.1.0 https://github.com/it-blaster/attach-file-bundle

Symfony2 bundle. The ability to attach files to the form.

  Sources   Download

MIT

The Requires

 

by IT-Blaster

form behavior type sluggable

21/04 2015

v1.0.0

1.0.0.0 https://github.com/it-blaster/attach-file-bundle

Symfony2 bundle. The ability to attach files to the form.

  Sources   Download

MIT

The Requires

 

by IT-Blaster

form behavior type sluggable