In Silex, the most common way to define the controller of a route is with a closure. But when your project gets bigger, you want to organize your code in classes. You can use the syntax ClassName::methodName
in your route definition instead of a function () { ... }
but you have to inject the Silex\Application $app
as a parameter on each method of your controller class, which can become quite boring.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not | |
// use this file except in compliance with the License. You may obtain a copy of | |
// the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
// License for the specific language governing permissions and limitations under |
#include <PMserial.h> | |
#include <BLEDevice.h> | |
#include <BLEUtils.h> | |
#include <BLEScan.h> | |
#include <BLEAdvertisedDevice.h> | |
#include <BLE2902.h> | |
#define SERVICE_UUID "faf6c799-5567-4f54-89fb-c7188b3f3b88" | |
#define CHARACTERISTIC_PM01_UUID "cc4f2f18-7b99-4fae-b46d-3568a42cb3f8" | |
#define CHARACTERISTIC_PM25_UUID "d7f6bea5-4e01-458d-9395-9e42ddd00b69" |
(ns taskbot.telegram | |
(:require [clj-http.client :as http] | |
[cheshire.core :as json] | |
[clojure.core.async :as a :refer [chan put! close! take! go go-loop <! >! alts!]] | |
[environ.core :refer [env]] | |
[clojure.tools.logging :as log] | |
[clojure.spec.alpha :as s] | |
[clojure.spec.test.alpha :refer [instrument]])) | |
(def base-url (or (env :base-url) "https://api.telegram.org/bot")) |
<div class="zoom_controls"> | |
<span><?php echo $this->tr('Zoom:')?></span> | |
<a href="#" data-chart="line" data-range="1m">1m</a> | |
<a href="#" data-chart="line" data-range="3m">3m</a> | |
<a href="#" data-chart="line" data-range="6m">6m</a> | |
<a href="#" data-chart="line" data-range="1y">1y</a> | |
<a href="#" data-chart="line" data-range="Ytd">YTD</a> | |
<a href="#" data-chart="line" data-range="All">All</a> | |
</div> | |
const webpack = require('webpack') | |
const path = require('path') | |
const devBuild = process.env.NODE_ENV !== 'production' | |
const nodeEnv = devBuild ? 'development' : 'production' | |
const config = { | |
entry: { | |
'client-bundle': [ 'babel-polyfill', 'whatwg-fetch', './app/Resources/js/main.js' ], |
Twig is the Chyrp templating engine. It is authored by Armin Ronacher, who was generous enough to jump on the chance to build us a templating engine. The syntax in general is “similar to the Genshi text templates which in turn were inspired by Django which also inspired Jinja (all three of them python template engines) which inspired the Twig runtime environment.”
A language independent and simple template engine is useful for applications that use code which is written in more than one programming language. Good Examples are portal systems which use a blog written in Ruby, a forum software written in PHP and a planet system written in Python.
While it was written for Chyrp exclusively, you should fairly easily be able to use it in any other system you want to use it in. Currently there is only one implementation, and that is in PHP. If you want to port it to another language, a spec sheet can be found in /includes/class/Twig/spec.html
.
<?php | |
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | |
class ServiceTest extends KernelTestCase | |
{ | |
public function provideExpectedDefinitions() | |
{ | |
return [ | |
['My\Something', 'my.something'], |
<?php | |
/** | |
* WebTestCase client-aware test case | |
*/ | |
trait ClientAware | |
{ | |
/** | |
* @var \Symfony\Bundle\FrameworkBundle\Client | |
*/ | |
private $client; |
Feature: Good SEO | |
As a worried customer | |
I expect my SEO to be good | |
Scenario: My SEO is good | |
When I search for "скачать бесплатно без регистрации и смс" on "http://google.com" | |
Then my shitty website should be at least on the "4"th line |