The most important rule for creating URLs in your site is to always do so using the URL manager. The URL manager is a built-in application component named `urlManager`. This component is accessible from both web and console applications via
`\Yii::$app->urlManager`. The component makes availabe the two following URL creation methods:
`\Yii::$app->urlManager`. The component makes available the two following URL creation methods:
The following code style is used for Yii 2.x core and official extensions development. If you want to pull-request code into the core, consider using it. We aren't forcing you to use this code style for your application. Feel free to choose what suits you better.
The following code style is used for Yii 2.x core and official extensions development. If you want to pull-request code
into the core, consider using it. We aren't forcing you to use this code style for your application. Feel free to choose
what suits you better.
You can get a config for CodeSniffer here: https://github.com/yiisoft/yii2-coding-standards
1. Overview
-----------
Overall we're using [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
compatible style so everything that applies to
[PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) is applied to our code
style as well.
- Files MUST use either `<?php` or `<?=` tags.
- There should be a newline at the end of file.
- Files MUST use only UTF-8 without BOM for PHP code.
- Code MUST use tabs for indenting, not spaces.
- Code MUST use 4 spaces for indenting, not tabs.
- Class names MUST be declared in `StudlyCaps`.
- Class constants MUST be declared in all upper case with underscore separators.
- Enh #497: Removed `\yii\log\Target::logUser` and added `\yii\log\Target::prefix` to support customizing message prefix (qiangxue)
- Enh #797: Added support for validating multiple columns by `UniqueValidator` and `ExistValidator` (qiangxue)
- Enh #802: Added support for retrieving sub-array element or child object property through `ArrayHelper::getValue()` (qiangxue, cebe)
- Enh #938: Added `yii\web\View::renderAjax()` and `yii\web\Controller::renderAjax()` (qiangxue)
...
...
@@ -146,6 +148,7 @@ Yii Framework 2 Change Log
- Enh #2729: Added `FilterValidator::skipOnArray` so that filters like `trim` will not fail for array inputs (qiangxue)
- Enh #2735: Added support for `DateTimeInterface` in `Formatter` (ivokund)
- Enh #2756: Added support for injecting custom `isEmpty` check for all validators (qiangxue)
- Enh #2775: Added `yii\base\Application::bootstrap` to support running bootstrap classes when starting an application (qiangxue)
- Enh: Added support for using arrays as option values for console commands (qiangxue)
- Enh: Added `favicon.ico` and `robots.txt` to default application templates (samdark)
- Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue)
...
...
@@ -241,6 +244,7 @@ Yii Framework 2 Change Log
- Renamed `yii\web\User::returnUrlVar` to `returnUrlParam`
- Chg: Added `View::viewFile` and removed `ViewEvent::viewFile` (qiangxue)
- Chg: Changed `Controller::afterAction()`, `Module::afterAction()` and `ActionFilter::afterAction()` to pass `$result` by value instead of reference (qiangxue)
- Chg: `yii\base\Extension::init()` is renamed to `bootstrap()` (qiangxue)
'The file "{file}" is not an image.'=>'Tiedosto "{file}" ei ole kuva.',
'The file "{file}" is too big. Its size cannot exceed {limit, number} {limit, plural, one{byte} other{bytes}}.'=>'Tiedosto "{file}" on liian iso. Sen koko ei voi olla suurempi kuin {limit, number} {limit, plural, one{tavu} other{tavua}}.',
'The file "{file}" is too small. Its size cannot be smaller than {limit, number} {limit, plural, one{byte} other{bytes}}.'=>'Tiedosto "{file}" on liian pieni. Sen koko ei voi olla pienempi kuin {limit, number} {limit, plural, one{tavu} other{tavua}}.',
'The format of {attribute} is invalid.'=>'Attribuutin {attribute} formaatti on virheellinen.',
'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.'=>'Kuva "{file}" on liian suuri. Korkeus ei voi olla suurempi kuin {limit, number} {limit, plural, one{pikseli} other{pikseliä}}.',
'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.'=>'Kuva "{file}" on liian suuri. Leveys ei voi olla suurempi kuin {limit, number} {limit, plural, one{pikseli} other{pikseliä}}.',
'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.'=>'Kuva "{file}" on liian pieni. Korkeus ei voi olla pienempi kuin {limit, number} {limit, plural, one{pikseli} other{pikseliä}}.',
'The image "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.'=>'Kuva "{file}" on liian pieni. Leveys ei voi olla pienempi kuin {limit, number} {limit, plural, one{pikseli} other{pikseliä}}.',
'The verification code is incorrect.'=>'Vahvistuskoodi on virheellinen.',
'You are not allowed to perform this action.'=>'Sinulla ei ole tarvittavia oikeuksia toiminnon suorittamiseen.',
'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.'=>'Voit lähettää enintään {limit, number} {limit, plural, one{tiedoston} other{tiedostoa}}.',
'the input value'=>'tuloarvo',
'{attribute} "{value}" has already been taken.'=>'{attribute} "{value}" on jo käytössä.',
'{attribute} cannot be blank.'=>'{attribute} ei voi olla tyhjä.',
'{attribute} is invalid.'=>'{attribute} on virheellinen.',
'{attribute} is not a valid URL.'=>'{attribute} on virheellinen URL.',
'{attribute} is not a valid email address.'=>'{attribute} on virheellinen sähköpostiosoite.',
'{attribute} must be "{requiredValue}".'=>'{attribute} täytyy olla "{requiredValue}".',
'{attribute} must be a number.'=>'{attribute} täytyy olla luku.',
'{attribute} must be a string.'=>'{attribute} täytyy olla merkkijono.',
'{attribute} must be an integer.'=>'{attribute} täytyy olla kokonaisluku.',
'{attribute} must be either "{true}" or "{false}".'=>'{attribute} täytyy olla joko {true} tai {false}.',
'{attribute} must be greater than "{compareValue}".'=>'{attribute} täytyy olla suurempi kuin "{compareValue}".',
'{attribute} must be greater than or equal to "{compareValue}".'=>'{attribute} täytyy olla suurempi tai yhtä suuri kuin "{compareValue}".',
'{attribute} must be less than "{compareValue}".'=>'{attribute} täytyy olla pienempi kuin "{compareValue}".',
'{attribute} must be less than or equal to "{compareValue}".'=>'{attribute} täytyy olla pienempi tai yhtä suuri kuin "{compareValue}".',
'{attribute} must be no greater than {max}.'=>'{attribute} ei saa olla suurempi kuin "{max}".',
'{attribute} must be no less than {min}.'=>'{attribute} ei saa olla pienempi kuin "{min}".',
'{attribute} must be repeated exactly.'=>'{attribute} täytyy toistaa täsmälleen.',
'{attribute} must not be equal to "{compareValue}".'=>'{attribute} ei saa olla yhtä suuri kuin "{compareValue}".',
'{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.'=>'{attribute} tulisi sisältää vähintään {min, number} {min, plural, one{merkki} other{merkkiä}}.',
'{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.'=>'{attribute} tulisi sisältää enintään {max, number} {max, plural, one{merkki} other{merkkiä}}.',
'{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.'=>'{attribute} tulisi sisältää {length, number} {length, plural, one{merkki} other{merkkiä}}.',
'{attribute} must be less than "{compareValue}".'=>'{attribute} moet minder zijn dan "{compareValue}".',
'{attribute} must be less than or equal to "{compareValue}".'=>'{attribute} moet minder dan of gelijk aan "{compareValue}" zijn.',
'{attribute} must be no greater than {max}.'=>'{attribute} mag niet groter zijn dan {max}.',
'{attribute} must be no less than {min}.'=>'{attribute} mag niet kleiner zijn dan {max}.',
'{attribute} must be no less than {min}.'=>'{attribute} mag niet kleiner zijn dan {min}.',
'{attribute} must be repeated exactly.'=>'{attribute} moet exact herhaald worden.',
'{attribute} must not be equal to "{compareValue}".'=>'{attribute} mag niet gelijk zijn aan "{compareValue}".',
'{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.'=>'{attribute} moet minstens {min, number} {min, plural, one{karakter} other{karakters}} bevatten.',
@@ -132,7 +132,7 @@ class ImageValidator extends FileValidator
$this->overHeight=Yii::t('yii','The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
}
if($this->wrongMimeType===null){
$this->wrongMimeType=Yii::t('yii','Only files with these mimeTypes are allowed: {mimeTypes}.');
$this->wrongMimeType=Yii::t('yii','Only files with these MIME types are allowed: {mimeTypes}.');
varhljs=newfunction(){functionl(o){returno.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}functionb(p){for(varo=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){returno}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}functionh(p,o){returnArray.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){returno?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}returnh(q,o)}).join("")}functiona(q){varp=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){returnr.replace(/^language-/,"")});for(varo=0;o<p.length;o++){if(e[p[o]]||p[o]=="no-highlight"){returnp[o]}}}functionc(q){varo=[];(functionp(r,s){for(vart=r.firstChild;t;t=t.nextSibling){if(t.nodeType==3){s+=t.nodeValue.length}else{if(t.nodeName=="BR"){s+=1}else{if(t.nodeType==1){o.push({event:"start",offset:s,node:t});s=p(t,s);o.push({event:"stop",offset:s,node:t})}}}}returns})(q,0);returno}functionj(x,v,w){varp=0;vary="";varr=[];functiont(){if(x.length&&v.length){if(x[0].offset!=v[0].offset){return(x[0].offset<v[0].offset)?x:v}else{returnv[0].event=="start"?x:v}}else{returnx.length?x:v}}functions(A){functionz(B){return" "+B.nodeName+'="'+l(B.value)+'"'}return"<"+A.nodeName+Array.prototype.map.call(A.attributes,z).join("")+">"}while(x.length||v.length){varu=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){varo,q=r.length;do{q--;o=r[q];y+=("</"+o.nodeName.toLowerCase()+">")}while(o!=u.node);r.splice(q,1);while(q<r.length){y+=s(r[q]);q++}}}}returny+l(w.substr(p))}functionf(q){functiono(s,r){returnRegExp(s,"m"+(q.cI?"i":"")+(r?"g":""))}functionp(y,w){if(y.compiled){return}y.compiled=true;vars=[];if(y.k){varr={};functionz(A,t){t.split(" ").forEach(function(B){varC=B.split("|");r[C[0]]=[A,C[1]?Number(C[1]):1];s.push(C[0])})}y.lR=o(y.l||hljs.IR,true);if(typeofy.k=="string"){z("keyword",y.k)}else{for(varxiny.k){if(!y.k.hasOwnProperty(x)){continue}z(x,y.k[x])}}y.k=r}if(w){if(y.bWK){y.b="\\b("+s.join("|")+")\\s"}y.bR=o(y.b?y.b:"\\B|\\b");if(!y.e&&!y.eW){y.e="\\B|\\b"}if(y.e){y.eR=o(y.e)}y.tE=y.e||"";if(y.eW&&w.tE){y.tE+=(y.e?"|":"")+w.tE}}if(y.i){y.iR=o(y.i)}if(y.r===undefined){y.r=1}if(!y.c){y.c=[]}for(varv=0;v<y.c.length;v++){if(y.c[v]=="self"){y.c[v]=y}p(y.c[v],y)}if(y.starts){p(y.starts,w)}varu=[];for(varv=0;v<y.c.length;v++){u.push(y.c[v].b)}if(y.tE){u.push(y.tE)}if(y.i){u.push(y.i)}y.t=u.length?o(u.join("|"),true):{exec:function(t){returnnull}}}p(q)}functiond(D,E){functiono(r,M){for(varL=0;L<M.c.length;L++){varK=M.c[L].bR.exec(r);if(K&&K.index==0){returnM.c[L]}}}functions(K,r){if(K.e&&K.eR.test(r)){returnK}if(K.eW){returns(K.parent,r)}}functiont(r,K){returnK.i&&K.iR.test(r)}functiony(L,r){varK=F.cI?r[0].toLowerCase():r[0];returnL.k.hasOwnProperty(K)&&L.k[K]}functionG(){varK=l(w);if(!A.k){returnK}varr="";varN=0;A.lR.lastIndex=0;varL=A.lR.exec(K);while(L){r+=K.substr(N,L.index-N);varM=y(A,L);if(M){v+=M[1];r+='<span class="'+M[0]+'">'+L[0]+"</span>"}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}returnr+K.substr(N)}functionz(){if(A.sL&&!e[A.sL]){returnl(w)}varr=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return'<span class="'+r.language+'">'+r.value+"</span>"}functionJ(){returnA.sL!==undefined?z():G()}functionI(L,r){varK=L.cN?'<span class="'+L.cN+'">':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}functionC(K,r){w+=K;if(r===undefined){x+=J();return0}varL=o(r,A);if(L){x+=J();I(L,r);returnL.rB?0:r.length}varM=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+="</span>"}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}returnM.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;returnr.length||1}varF=e[D];f(F);varA=F;varw="";varB=0;varv=0;varx="";try{varu,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throwH}}}functiong(s){varo={keyword_count:0,r:0,value:l(s)};varq=o;for(varpine){if(!e.hasOwnProperty(p)){continue}varr=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}returno}functioni(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){returnv.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"<br>")}returnq}functionm(r,u,p){varv=h(r,p);vart=a(r);if(t=="no-highlight"){return}varw=t?d(t,v):g(v);t=w.language;varo=c(r);if(o.length){varq=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);vars=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}functionn(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}functionk(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}vare={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){varo={};for(varpinq){o[p]=q[p]}if(r){for(varpinr){o[p]=r[p]}}returno}}();hljs.LANGUAGES.php=function(a){vare={cN:"variable",b:"\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*"};varb=[a.inherit(a.ASM,{i:null}),a.inherit(a.QSM,{i:null}),{cN:"string",b:'b"',e:'"',c:[a.BE]},{cN:"string",b:"b'",e:"'",c:[a.BE]}];varc=[a.BNM,a.CNM];vard={cN:"title",b:a.UIR};return{cI:true,k:"and include_once list abstract global private echo interface as static endswitch array null if endwhile or const for endforeach self var while isset public protected exit foreach throw elseif include __FILE__ empty require_once do xor return implements parent clone use __CLASS__ __LINE__ else break print eval new catch __METHOD__ case exception php_user_filter default die require __FUNCTION__ enddeclare final try this switch continue endfor endif declare unset true false namespace trait goto instanceof insteadof __DIR__ __NAMESPACE__ __halt_compiler",c:[a.CLCM,a.HCM,{cN:"comment",b:"/\\*",e:"\\*/",c:[{cN:"phpdoc",b:"\\s@[A-Za-z]+"}]},{cN:"comment",eB:true,b:"__halt_compiler.+?;",eW:true},{cN:"string",b:"<<<['\"]?\\w+['\"]?$",e:"^\\w+;",c:[a.BE]},{cN:"preprocessor",b:"<\\?php",r:10},{cN:"preprocessor",b:"\\?>"},e,{cN:"function",bWK:true,e:"{",k:"function",i:"\\$|\\[|%",c:[d,{cN:"params",b:"\\(",e:"\\)",c:["self",e,a.CBLCLM].concat(b).concat(c)}]},{cN:"class",bWK:true,e:"{",k:"class",i:"[:\\(\\$]",c:[{bWK:true,eW:true,k:"extends",c:[d]},d]},{b:"=>"}].concat(b).concat(c)}}(hljs);