appventus/shortcuts-bundle

此包已被弃用且不再维护。未建议替代包。

Symfony ShortcutsBundle

安装次数: 17 519

依赖项: 2

建议者: 0

安全: 0

星级: 5

关注者: 11

分支: 7

公开问题: 0

语言:JavaScript

类型:symfony-bundle

1.1 2017-07-16 13:58 UTC

This package is auto-updated.

Last update: 2021-12-21 22:36:10 UTC


README

AppVentus

Gitter License Version

Awesome Shortcuts Bundle

这是为什么?

此包允许您轻松添加和使用开发应用程序的快捷方式。

安装

此过程描述了在虚拟机 vagrant 中使用项目的过程。

恢复包

Composer

在您的 composer.json 中添加以下行

    {
        "require": {
            "appventus/shortcuts-bundle": "dev-master"
        }
    }

然后执行以下命令

    php composer.phar update

包激活

在您的 AppKernel.php 中添加以下行

<?php

public function registerBundles()
{
    $bundles = array(
        // ...
        new AppVentus\Awesome\ShortcutsBundle\AvAwesomeShortcutsBundle(),
    );
}

配置

Twig

在 Config.yml 中添加以下行

    # Sf=2.*
    twig:
        form:
            resources:
                - 'AvAwesomeShortcutsBundle::fields.html.twig'# Twig Configuration
    # Sf>=3.*
    twig:
        form_themes:
            - 'AvAwesomeShortcutsBundle::fields.html.twig'

在您的布局文件中,加载以下文件

    '@AvAwesomeShortcutsBundle/Resources/public/css/datepicker.css'
    '@AvAwesomeShortcutsBundle/Resources/public/js/bootstrap-datepicker.js'

使用快捷方式

一个服务允许使用在许多应用程序中使用的函数。

例如,在控制器中

$shorcutService = $this->get('av.shorcuts');
$shorcutService->getSession(...
$shorcutService->setSession(...
$shorcutService->createAndQueueMail(...
$shorcutService->createAndSendMail(...

查看ShortcutService 文件以获取快捷方式及其参数的完整列表。

FormErrorService

由于通常通过ajax提交表单,因此希望返回字符串形式的错误表单。

FormErrorService 将表单(及其子表单)上的错误转换为字符串。

例如,在控制器中

	$form = ...  //some form

	if ($form->isValid()) {
		...
	} else {
		$formErrorService = $this->get('av.form_error_service');
		$errorsAsString = $formErrorService->getRecursiveReadableErrors($form);
	}

AvAlertifyBundle 集成

此包为 AvAlertify bundle 提供了大量的快捷方式,以标准化您应用程序的所有警告。

我们可以现在使用来自 av.shortcuts 服务的以下快捷方式

$this->get('session')->getFlashBag()->add('noty', array(
        'type'              => $type,
        'layout'            => $layout,
        'body'              => $content,
        'translationDomain' => $translationDomain
    )
);

或者更糟糕的

$this->session->getFlashBag()->add('success', 'Congratulations !');

现在我们可以使用以下来自 av.shortcuts 服务的快捷方式

$this->container->get('av.shortcuts')->congrat($content, $layout, $translationDomain);

或者任何继承自 AwesomeController 的我们的控制器

$this->congrat('Congratulations !');         // Success
$this->warn('Careful, this is important !'); // Warning
$this->inform('Did you know ?');             // Information
$this->scold('Oups something went wrong !'); // Error

RedactorType

添加资产注入器 redactor 标签

$redactorOptions = [
    'lang' => $this->request->getLocale(),
    'plugins' => ['video'],
    'buttons' => ['html', 'formatting', 'bold', 'italic', 'underline', 'deleted', 'unorderedlist', 'orderedlist', 'outdent', 'indent', 'image', 'video', 'link', 'alignment', 'horizontalrule'],
    'imageUpload' => '/bundles/avawesomeshortcuts/libs/redactor/scripts/image_upload.php',
];

$builder->add('description', RedactorType::class, [
	'options' => $redactorOptions
]);